problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static int parse_source_parameters(AVDiracSeqHeader *dsh, GetBitContext *gb,
void *log_ctx)
{
AVRational frame_rate = { 0, 0 };
unsigned luma_depth = 8, luma_offset = 16;
int idx;
int chroma_x_shift, chroma_y_shift;
if (get_bits1(gb)) {
dsh->width = svq3_get_ue_golomb(gb);
dsh->height = svq3_get_ue_golomb(gb);
}
if (get_bits1(gb))
dsh->chroma_format = svq3_get_ue_golomb(gb);
if (dsh->chroma_format > 2U) {
if (log_ctx)
av_log(log_ctx, AV_LOG_ERROR, "Unknown chroma format %d\n",
dsh->chroma_format);
}
if (get_bits1(gb))
dsh->interlaced = svq3_get_ue_golomb(gb);
if (dsh->interlaced > 1U)
if (get_bits1(gb)) {
dsh->frame_rate_index = svq3_get_ue_golomb(gb);
if (dsh->frame_rate_index > 10U)
if (!dsh->frame_rate_index) {
frame_rate.num = svq3_get_ue_golomb(gb);
frame_rate.den = svq3_get_ue_golomb(gb);
}
}
if (dsh->frame_rate_index > 0) {
if (dsh->frame_rate_index <= 8)
frame_rate = ff_mpeg12_frame_rate_tab[dsh->frame_rate_index];
else
frame_rate = dirac_frame_rate[dsh->frame_rate_index - 9];
}
dsh->framerate = frame_rate;
if (get_bits1(gb)) {
dsh->aspect_ratio_index = svq3_get_ue_golomb(gb);
if (dsh->aspect_ratio_index > 6U)
if (!dsh->aspect_ratio_index) {
dsh->sample_aspect_ratio.num = svq3_get_ue_golomb(gb);
dsh->sample_aspect_ratio.den = svq3_get_ue_golomb(gb);
}
}
if (dsh->aspect_ratio_index > 0)
dsh->sample_aspect_ratio =
dirac_preset_aspect_ratios[dsh->aspect_ratio_index - 1];
if (get_bits1(gb)) {
dsh->clean_width = svq3_get_ue_golomb(gb);
dsh->clean_height = svq3_get_ue_golomb(gb);
dsh->clean_left_offset = svq3_get_ue_golomb(gb);
dsh->clean_right_offset = svq3_get_ue_golomb(gb);
}
if (get_bits1(gb)) {
dsh->pixel_range_index = svq3_get_ue_golomb(gb);
if (dsh->pixel_range_index > 4U)
if (!dsh->pixel_range_index) {
luma_offset = svq3_get_ue_golomb(gb);
luma_depth = av_log2(svq3_get_ue_golomb(gb)) + 1;
svq3_get_ue_golomb(gb);
svq3_get_ue_golomb(gb);
dsh->color_range = luma_offset ? AVCOL_RANGE_MPEG
: AVCOL_RANGE_JPEG;
}
}
if (dsh->pixel_range_index > 0) {
idx = dsh->pixel_range_index - 1;
luma_depth = pixel_range_presets[idx].bitdepth;
dsh->color_range = pixel_range_presets[idx].color_range;
}
dsh->bit_depth = luma_depth;
dsh->pix_fmt = dirac_pix_fmt[dsh->chroma_format][dsh->pixel_range_index-2];
avcodec_get_chroma_sub_sample(dsh->pix_fmt, &chroma_x_shift, &chroma_y_shift);
if ((dsh->width % (1<<chroma_x_shift)) || (dsh->height % (1<<chroma_y_shift))) {
if (log_ctx)
av_log(log_ctx, AV_LOG_ERROR, "Dimensions must be an integer multiple of the chroma subsampling\n");
}
if (get_bits1(gb)) {
idx = dsh->color_spec_index = svq3_get_ue_golomb(gb);
if (dsh->color_spec_index > 4U)
dsh->color_primaries = dirac_color_presets[idx].color_primaries;
dsh->colorspace = dirac_color_presets[idx].colorspace;
dsh->color_trc = dirac_color_presets[idx].color_trc;
if (!dsh->color_spec_index) {
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
if (idx < 3U)
dsh->color_primaries = dirac_primaries[idx];
}
if (get_bits1(gb)) {
idx = svq3_get_ue_golomb(gb);
if (!idx)
dsh->colorspace = AVCOL_SPC_BT709;
else if (idx == 1)
dsh->colorspace = AVCOL_SPC_BT470BG;
}
if (get_bits1(gb) && !svq3_get_ue_golomb(gb))
dsh->color_trc = AVCOL_TRC_BT709;
}
} else {
idx = dsh->color_spec_index;
dsh->color_primaries = dirac_color_presets[idx].color_primaries;
dsh->colorspace = dirac_color_presets[idx].colorspace;
dsh->color_trc = dirac_color_presets[idx].color_trc;
}
return 0;
} | 1threat |
using flowtype to statically check mocha test code : <p>I have some complex Mocha code which I would like to statically check with FlowType because why not?</p>
<p>Below is a minimal repro:</p>
<pre><code>/* @flow */
describe('it', function () {
it('fails', function() {
const s: number = 'flow spots this error';
});
});
</code></pre>
<p>When I run Flow on this, Flow does indeed spot the problem with the assignment of <code>string</code> to <code>number</code> which shows that the approach is working to some extend.</p>
<p>However, I also get:</p>
<pre><code>test/test.js:4
4: describe('it', function () {
^^^^^^^^ identifier `describe`. Could not resolve name
test/test.js:5
5: it('fails', function() {
^^ identifier `it`. Could not resolve name
</code></pre>
<p>… apparently the Mocha test definitions run in an environment where these functions are globally available but looking at the test file there's nothing that would allow Flow to detect that.</p>
<p>I am not sure these problems are specific to Mocha but I don't feel I can confidently frame the question in broader terms, so my questions are:</p>
<ol>
<li>how can I have Flow type check Mocha test code without suppressing every line that contains <code>describe</code> or <code>it</code> ?</li>
<li>is this is an instance of a broader class of situations and, if so, what would the latter be?</li>
</ol>
| 0debug |
invalid syntax: my code looks the same as that in the book : <pre><code>states = [
'oregon': 'OR',
'florida': 'FL',
'california': 'CA',
'new york': 'NY',
'michigan': 'MI'
]
</code></pre>
<p>when I run code above, terminal always say:</p>
<pre><code>'oregon': 'OR',
^
SyntaxError: invalid syntax
</code></pre>
<p>But I just copy the code in a book, not exactly copy&paste, but type them manually and they look the same. I don't know what's going wrong.
hope someone can help me with that. thanks!!</p>
| 0debug |
void migration_tls_channel_connect(MigrationState *s,
QIOChannel *ioc,
const char *hostname,
Error **errp)
{
QCryptoTLSCreds *creds;
QIOChannelTLS *tioc;
creds = migration_tls_get_creds(
s, QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT, errp);
if (!creds) {
return;
}
if (s->parameters.tls_hostname) {
hostname = s->parameters.tls_hostname;
}
if (!hostname) {
error_setg(errp, "No hostname available for TLS");
return;
}
tioc = qio_channel_tls_new_client(
ioc, creds, hostname, errp);
if (!tioc) {
return;
}
trace_migration_tls_outgoing_handshake_start(hostname);
qio_channel_set_name(QIO_CHANNEL(tioc), "migration-tls-outgoing");
qio_channel_tls_handshake(tioc,
migration_tls_outgoing_handshake,
s,
NULL);
}
| 1threat |
Typehints for Sized Iterable in Python : <p>I have a function that uses the <code>len</code> function on one of it's parameters and iterates over the parameter. Now I can choose whether to annotate the type with <code>Iterable</code> or with <code>Sized</code>, but both gives errors in <code>mypy</code>.</p>
<pre><code>from typing import Sized, Iterable
def foo(some_thing: Iterable):
print(len(some_thing))
for part in some_thing:
print(part)
</code></pre>
<p>Gives</p>
<pre><code>error: Argument 1 to "len" has incompatible type "Iterable[Any]"; expected "Sized"
</code></pre>
<p>While</p>
<pre><code>def foo(some_thing: Sized):
...
</code></pre>
<p>Gives</p>
<pre><code>error: Iterable expected
error: "Sized" has no attribute "__iter__"
</code></pre>
<p>Since there is no <code>Intersection</code> as discussed in <a href="https://github.com/python/typing/issues/213" rel="noreferrer">this issue</a> I need to have some kind of mixed class.</p>
<pre><code>from abc import ABCMeta
from typing import Sized, Iterable
class SizedIterable(Sized, Iterable[str], metaclass=ABCMeta):
pass
def foo(some_thing: SizedIterable):
print(len(some_thing))
for part in some_thing:
print(part)
foo(['a', 'b', 'c'])
</code></pre>
<p>This gives an error when using <code>foo</code> with a <code>list</code>.</p>
<pre><code>error: Argument 1 to "foo" has incompatible type "List[str]"; expected "SizedIterable"
</code></pre>
<p>This is not too surprising since:</p>
<pre><code>>>> SizedIterable.__subclasscheck__(list)
False
</code></pre>
<p>So I defined a <code>__subclasshook__</code> (see <a href="https://docs.python.org/3/library/abc.html#abc.ABCMeta.__subclasshook__" rel="noreferrer">docs</a>).</p>
<pre><code>class SizedIterable(Sized, Iterable[str], metaclass=ABCMeta):
@classmethod
def __subclasshook__(cls, subclass):
return Sized.__subclasscheck__(subclass) and Iterable.__subclasscheck__(subclass)
</code></pre>
<p>Then the subclass check works:</p>
<pre><code>>>> SizedIterable.__subclasscheck__(list)
True
</code></pre>
<p>But <code>mypy</code> still complains about my <code>list</code>.</p>
<pre><code>error: Argument 1 to "foo" has incompatible type "List[str]"; expected "SizedIterable"
</code></pre>
<p>How can I use type hints when using both the <code>len</code> function and iterate over my parameter? I think casting <code>foo(cast(SizedIterable, ['a', 'b', 'c']))</code> is not a good solution.</p>
| 0debug |
I am making full stack app using react & node , how should I design my database (Schema) : How should I approach to schema design for my app ? What are the important points to remember when doing schema design & How should be different models in my node app relate to each other. Any explanation for simple CRUD App | 0debug |
static void xen_sysdev_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
k->init = xen_sysdev_init;
dc->props = xen_sysdev_properties;
dc->bus_type = TYPE_XENSYSBUS;
} | 1threat |
static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
struct elfhdr *exec,
struct image_info *info,
struct image_info *interp_info)
{
abi_ulong sp;
abi_ulong u_argc, u_argv, u_envp, u_auxv;
int size;
int i;
abi_ulong u_rand_bytes;
uint8_t k_rand_bytes[16];
abi_ulong u_platform;
const char *k_platform;
const int n = sizeof(elf_addr_t);
sp = p;
#ifdef CONFIG_USE_FDPIC
if (elf_is_fdpic(exec)) {
sp &= ~3;
sp = loader_build_fdpic_loadmap(info, sp);
info->other_info = interp_info;
if (interp_info) {
interp_info->other_info = info;
sp = loader_build_fdpic_loadmap(interp_info, sp);
}
}
#endif
u_platform = 0;
k_platform = ELF_PLATFORM;
if (k_platform) {
size_t len = strlen(k_platform) + 1;
if (STACK_GROWS_DOWN) {
sp -= (len + n - 1) & ~(n - 1);
u_platform = sp;
memcpy_to_target(sp, k_platform, len);
} else {
memcpy_to_target(sp, k_platform, len);
u_platform = sp;
sp += len + 1;
}
}
if (STACK_GROWS_DOWN) {
sp = QEMU_ALIGN_DOWN(sp, 16);
} else {
sp = QEMU_ALIGN_UP(sp, 16);
}
for (i = 0; i < 16; i++) {
k_rand_bytes[i] = rand();
}
if (STACK_GROWS_DOWN) {
sp -= 16;
u_rand_bytes = sp;
memcpy_to_target(sp, k_rand_bytes, 16);
} else {
memcpy_to_target(sp, k_rand_bytes, 16);
u_rand_bytes = sp;
sp += 16;
}
size = (DLINFO_ITEMS + 1) * 2;
if (k_platform)
size += 2;
#ifdef DLINFO_ARCH_ITEMS
size += DLINFO_ARCH_ITEMS * 2;
#endif
#ifdef ELF_HWCAP2
size += 2;
#endif
size += envc + argc + 2;
size += 1;
size *= n;
if (STACK_GROWS_DOWN) {
u_argc = QEMU_ALIGN_DOWN(sp - size, STACK_ALIGNMENT);
sp = u_argc;
} else {
u_argc = sp;
sp = QEMU_ALIGN_UP(sp + size, STACK_ALIGNMENT);
}
u_argv = u_argc + n;
u_envp = u_argv + (argc + 1) * n;
u_auxv = u_envp + (envc + 1) * n;
info->saved_auxv = u_auxv;
info->arg_start = u_argv;
info->arg_end = u_argv + argc * n;
#define NEW_AUX_ENT(id, val) do { \
put_user_ual(id, u_auxv); u_auxv += n; \
put_user_ual(val, u_auxv); u_auxv += n; \
} while(0)
#ifdef ARCH_DLINFO
ARCH_DLINFO;
#endif
NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff));
NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr)));
NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum));
NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, getpagesize())));
NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr : 0));
NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0);
NEW_AUX_ENT(AT_ENTRY, info->entry);
NEW_AUX_ENT(AT_UID, (abi_ulong) getuid());
NEW_AUX_ENT(AT_EUID, (abi_ulong) geteuid());
NEW_AUX_ENT(AT_GID, (abi_ulong) getgid());
NEW_AUX_ENT(AT_EGID, (abi_ulong) getegid());
NEW_AUX_ENT(AT_HWCAP, (abi_ulong) ELF_HWCAP);
NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK));
NEW_AUX_ENT(AT_RANDOM, (abi_ulong) u_rand_bytes);
#ifdef ELF_HWCAP2
NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
#endif
if (u_platform) {
NEW_AUX_ENT(AT_PLATFORM, u_platform);
}
NEW_AUX_ENT (AT_NULL, 0);
#undef NEW_AUX_ENT
info->auxv_len = u_argv - info->saved_auxv;
put_user_ual(argc, u_argc);
p = info->arg_strings;
for (i = 0; i < argc; ++i) {
put_user_ual(p, u_argv);
u_argv += n;
p += target_strlen(p) + 1;
}
put_user_ual(0, u_argv);
p = info->env_strings;
for (i = 0; i < envc; ++i) {
put_user_ual(p, u_envp);
u_envp += n;
p += target_strlen(p) + 1;
}
put_user_ual(0, u_envp);
return sp;
}
| 1threat |
What's 0xFF for in cv2.waitKey(1)? : <p>I'm trying understand what 0xFF does under the hood in the following code snippet:</p>
<pre><code>if cv2.waitKey(0) & 0xFF == ord('q'):
break
</code></pre>
<p>Any ideas?</p>
| 0debug |
static int find_and_decode_index(NUTContext *nut){
AVFormatContext *s= nut->avf;
ByteIOContext *bc = s->pb;
uint64_t tmp, end;
int i, j, syncpoint_count;
int64_t filesize= url_fsize(bc);
int64_t *syncpoints;
int8_t *has_keyframe;
url_fseek(bc, filesize-12, SEEK_SET);
url_fseek(bc, filesize-get_be64(bc), SEEK_SET);
if(get_be64(bc) != INDEX_STARTCODE){
av_log(s, AV_LOG_ERROR, "no index at the end\n");
return -1;
}
end= get_packetheader(nut, bc, 1, INDEX_STARTCODE);
end += url_ftell(bc);
ff_get_v(bc);
GET_V(syncpoint_count, tmp < INT_MAX/8 && tmp > 0)
syncpoints= av_malloc(sizeof(int64_t)*syncpoint_count);
has_keyframe= av_malloc(sizeof(int8_t)*(syncpoint_count+1));
for(i=0; i<syncpoint_count; i++){
GET_V(syncpoints[i], tmp>0)
if(i)
syncpoints[i] += syncpoints[i-1];
}
for(i=0; i<s->nb_streams; i++){
int64_t last_pts= -1;
for(j=0; j<syncpoint_count;){
uint64_t x= ff_get_v(bc);
int type= x&1;
int n= j;
x>>=1;
if(type){
int flag= x&1;
x>>=1;
if(n+x >= syncpoint_count + 1){
av_log(s, AV_LOG_ERROR, "index overflow A\n");
return -1;
}
while(x--)
has_keyframe[n++]= flag;
has_keyframe[n++]= !flag;
}else{
while(x != 1){
if(n>=syncpoint_count + 1){
av_log(s, AV_LOG_ERROR, "index overflow B\n");
return -1;
}
has_keyframe[n++]= x&1;
x>>=1;
}
}
if(has_keyframe[0]){
av_log(s, AV_LOG_ERROR, "keyframe before first syncpoint in index\n");
return -1;
}
assert(n<=syncpoint_count+1);
for(; j<n; j++){
if(has_keyframe[j]){
uint64_t B, A= ff_get_v(bc);
if(!A){
A= ff_get_v(bc);
B= ff_get_v(bc);
}else
B= 0;
av_add_index_entry(
s->streams[i],
16*syncpoints[j-1],
last_pts + A,
0,
0,
AVINDEX_KEYFRAME);
last_pts += A + B;
}
}
}
}
if(skip_reserved(bc, end) || get_checksum(bc)){
av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
return -1;
}
return 0;
}
| 1threat |
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
{
pkt->data = NULL;
pkt->side_data = NULL;
if (pkt->buf) {
AVBufferRef *ref = av_buffer_ref(src->buf);
if (!ref)
return AVERROR(ENOMEM);
pkt->buf = ref;
pkt->data = ref->data;
} else {
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
}
if (pkt->side_data_elems && dup)
pkt->side_data = src->side_data;
if (pkt->side_data_elems && !dup) {
return av_copy_packet_side_data(pkt, src);
}
return 0;
failed_alloc:
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
| 1threat |
Aspect fit in cgsize programmatically in swift : <p><a href="https://i.stack.imgur.com/leswD.png" rel="nofollow noreferrer">Click here for image.</a></p>
<p>Need help fitting label so that the left and right side fills.
Code is at the bottom.</p>
<pre><code> @IBOutlet weak var header: UILabel!
override func viewDidLoad() {
header.adjustsFontSizeToFitWidth = true
let rectShape = CAShapeLayer()
rectShape.bounds = self.header.frame
rectShape.position = self.header.center
rectShape.path = UIBezierPath(roundedRect: self.header.bounds, byRoundingCorners: [.bottomLeft , .bottomRight], cornerRadii: CGSize(width:300, height: 200)).cgPath
self.header.layer.backgroundColor = UIColor.green.cgColor
//Here I'm masking the textView's layer with rectShape layer
self.header.layer.mask = rectShape
super.viewDidLoad()
</code></pre>
| 0debug |
Selecting List<string> into Dictionary with index : <p>I have a List</p>
<pre><code>List<string> sList = new List<string>() { "a","b","c"};
</code></pre>
<p>And currently I am selecting this into a dictionary the following structure:</p>
<pre><code>//(1,a)(2,b)(3,c)
Dictionary<int, string> dResult = new Dictionary<int, string>();
for(int i=0;i< sList.Count;i++)
{
dResult.Add(i, sList[i]);
}
</code></pre>
<p>but with Linq I've seen some slimmer way like <code>ToDictionary((x,index) =></code></p>
<p>How is the correct syntax or how can this be solved within one line?</p>
| 0debug |
django TypeError: get() got multiple values for keyword argument 'invoice_id' : <p>I am relatively new in python and django,</p>
<p>i have following rest api view,</p>
<pre><code>class InvoiceDownloadApiView(RetrieveAPIView):
"""
This API view will retrieve and send Terms and Condition file for download
"""
permission_classes = (IsAuthenticated,)
def get(self, invoice_id, *args, **kwargs):
if self.request.user.is_authenticated():
try:
invoice = InvoiceService(user=self.request.user, organization=self.request.organization).invoice_download(
invoice_id=invoice_id)
except ObjectDoesNotExist as e:
return Response(e.message, status=status.HTTP_404_NOT_FOUND)
if invoice:
response = HttpResponse(
invoice, content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename={0}'.format(
invoice.name.split('/')[-1])
response['X-Sendfile'] = smart_str(invoice)
return response
else:
return Response({"data": "Empty File"}, status=status.HTTP_400_BAD_REQUEST)
</code></pre>
<p>using following urls,</p>
<pre><code>urlpatterns = [
url(r'^invoice/(?P<invoice_id>[0-9]+)/download/$', views.InvoiceDownloadApiView.as_view()),
</code></pre>
<p>]</p>
<p>root url pattern is as following,</p>
<pre><code>url(r'^api/payments/', include('payments.rest_api.urls', namespace="payments")),
</code></pre>
<p>when i call the endpoint,</p>
<pre><code>localhost:8000/api/payments/invoice/2/download/
</code></pre>
<p>it arise the following error,</p>
<pre><code>TypeError at /api/payments/invoice/2/download/
get() got multiple values for keyword argument 'invoice_id'
</code></pre>
<p>can't figure it out what actually causing this error</p>
| 0debug |
How do I get the current date from my phone? : <p>So, my first app will be a personal one to help me meet deadlines. As you would imagine it is going to be very date oriented.</p>
<p>So, how do I grab the current date from my phone/emulator?</p>
<p><strong>Bonus points</strong> if you can explain how to put it into an integer.</p>
<p>Any link or tutorial would be super great.
Thanks in advance.</p>
| 0debug |
Javascript: Count occurrencies in array object : <p>If I have an array like this</p>
<pre><code> var array = [
{name: "Source_one", alertName: "Alert_1"},
{name: "Source_three", alertName: "Alert_2"},
{name: "Source_one", alertName: "Alert_3"},
{name: "Source_two", alertName: "Alert_3"},
{name: "Source_one", alertName: "Alert_3"},
{name: "Source_one", alertName: "Alert_3"},
{name: "Source_two", alertName: "Alert_1"},
{name: "Source_one", alertName: "Alert_1"},
{name: "Source_two", alertName: "Alert_1"},
{name: "Source_two", alertName: "Alert_2"},
{name: "Source_one", alertName: "Alert_1"},
{name: "Source_two", alertName: "Alert_2"},
{name: "Source_three", alertName: "Alert_3"},
{name: "Source_two", alertName: "Alert_2"},
{name: "Source_two", alertName: "Alert_3"},
{name: "Source_three", alertName: "Alert_1"},
{name: "Source_three", alertName: "Alert_1"},
{name: "Source_one", alertName: "Alert_3"},
{name: "Source_three", alertName: "Alert_2"},
{name: "Source_three", alertName: "Alert_2"},
{name: "Source_two", alertName: "Alert_1"},
{name: "Source_three", alertName: "Alert_3"}
]
</code></pre>
<p>how can I do if I want to know how may times each point happens for a single alert?</p>
<p>I would like to create this kind of output:</p>
<pre><code> var output = [
{name: "Source_one", alertName: "Alert_1", frequency:3},
{name: "Source_one", alertName: "Alert_3", frequency:4},
{name: "Source_two", alertName: "Alert_1", frequency:3},
{name: "Source_two", alertName: "Alert_2", frequency:3},
{name: "Source_two", alertName: "Alert_3", frequency:2},
{name: "Source_three", alertName: "Alert_1", frequency:2},
{name: "Source_three", alertName: "Alert_2", frequency:3},
{name: "Source_three", alertName: "Alert_3", frequency:2}
]
</code></pre>
<p>I really have no clue how to do that. Thanks for your help</p>
| 0debug |
int ff_audio_mix(AudioMix *am, AudioData *src)
{
int use_generic = 1;
int len = src->nb_samples;
int i, j;
if (am->has_optimized_func) {
int aligned_len = FFALIGN(len, am->samples_align);
if (!(src->ptr_align % am->ptr_align) &&
src->samples_align >= aligned_len) {
len = aligned_len;
use_generic = 0;
}
}
av_dlog(am->avr, "audio_mix: %d samples - %d to %d channels (%s)\n",
src->nb_samples, am->in_channels, am->out_channels,
use_generic ? am->func_descr_generic : am->func_descr);
if (am->in_matrix_channels && am->out_matrix_channels) {
uint8_t **data;
uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];
if (am->out_matrix_channels < am->out_channels ||
am->in_matrix_channels < am->in_channels) {
for (i = 0, j = 0; i < FFMAX(am->in_channels, am->out_channels); i++) {
if (am->input_skip[i] || am->output_skip[i] || am->output_zero[i])
continue;
data0[j++] = src->data[i];
}
data = data0;
} else {
data = src->data;
}
if (use_generic)
am->mix_generic(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
else
am->mix(data, am->matrix, len, am->out_matrix_channels,
am->in_matrix_channels);
}
if (am->out_matrix_channels < am->out_channels) {
for (i = 0; i < am->out_channels; i++)
if (am->output_zero[i])
av_samples_set_silence(&src->data[i], 0, len, 1, am->fmt);
}
ff_audio_data_set_channels(src, am->out_channels);
return 0;
}
| 1threat |
How can I raise a number to power in javascript? : <p>Please what is the simplest method to exponentiate a number
Cus I don't see it in the javascript arithematic operators </p>
| 0debug |
static inline void gen_movcf_ps(DisasContext *ctx, int fs, int fd,
int cc, int tf)
{
int cond;
TCGv_i32 t0 = tcg_temp_new_i32();
int l1 = gen_new_label();
int l2 = gen_new_label();
if (tf)
cond = TCG_COND_EQ;
else
cond = TCG_COND_NE;
tcg_gen_andi_i32(t0, fpu_fcr31, 1 << get_fp_bit(cc));
tcg_gen_brcondi_i32(cond, t0, 0, l1);
gen_load_fpr32(t0, fs);
gen_store_fpr32(t0, fd);
gen_set_label(l1);
tcg_gen_andi_i32(t0, fpu_fcr31, 1 << get_fp_bit(cc+1));
tcg_gen_brcondi_i32(cond, t0, 0, l2);
gen_load_fpr32h(ctx, t0, fs);
gen_store_fpr32h(ctx, t0, fd);
tcg_temp_free_i32(t0);
gen_set_label(l2);
}
| 1threat |
Android ExoPlayer not resuming after network is connected : <p>Im using <a href="https://github.com/google/ExoPlayer" rel="noreferrer">Exoplayer</a> for HLS Streaming in my App. Its playing nicely but when i disconnect the internet connection and enable it again,Exo player does not resume the video play.</p>
<p>Exoplayer is handling this by default or do i need to manually handle this? </p>
<p>here is my code..`</p>
<pre><code> public class PlayerActivity extends Activity implements SurfaceHolder.Callback, OnClickListener,
DemoPlayer.Listener, DemoPlayer.CaptionListener, DemoPlayer.Id3MetadataListener,
AudioCapabilitiesReceiver.Listener { public class PlayerActivity extends Activity implements SurfaceHolder.Callback, OnClickListener,
DemoPlayer.Listener, DemoPlayer.CaptionListener, DemoPlayer.Id3MetadataListener,
AudioCapabilitiesReceiver.Listener {
// For use within demo app code.
public static final String CONTENT_ID_EXTRA = "content_id";
public static final String CONTENT_TYPE_EXTRA = "content_type";
public static final String PROVIDER_EXTRA = "provider";
// For use when launching the demo app using adb.
private static final String CONTENT_EXT_EXTRA = "type";
private static final String TAG = "PlayerActivity";
private static final int MENU_GROUP_TRACKS = 1;
private static final int ID_OFFSET = 2;
private static final CookieManager defaultCookieManager;
static {
defaultCookieManager = new CookieManager();
defaultCookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
}
private EventLogger eventLogger;
private MediaController mediaController;
private View debugRootView;
private View shutterView;
private AspectRatioFrameLayout videoFrame;
private SurfaceView surfaceView;
private TextView debugTextView;
private TextView playerStateTextView;
private SubtitleLayout subtitleLayout;
private Button videoButton;
private Button audioButton;
private Button textButton;
private Button retryButton;
static TextView bitrateTextView;
private static DemoPlayer player;
private DebugTextViewHelper debugViewHelper;
private boolean playerNeedsPrepare;
private long playerPosition;
private boolean enableBackgroundAudio;
private Uri contentUri;
private int contentType;
private String contentId;
private String provider;
RotateAnimation rotate;
ImageView rotateLoad=null;
ImageView loadMid=null;
FrameLayout videoLoad;
private String vidLink ="";
private String title =""; private TextView vodTitle;
private String description =""; private TextView vodDesc;
private String vodimage =""; private ImageView vodThumb;
private String chimage =""; private ImageView chLogo;
private String datetitle =""; private TextView vodTimeDesc, videoCurrentTime, videoTimeEnd;
private Bitmap vodImgThumb, chImgLogo;
private static FrameLayout guideInfo;
private FrameLayout seekBar;
private FrameLayout playPause;
private int rewindRate = 1;
private int forwardRate = 1, stopPosition ;
private SeekBar sb;
CountDownTimer ct;
int infoFade = 0 , seekFade =0 , height, width;
private boolean isPlaying = false;
static long storeBitRate;
private AudioCapabilitiesReceiver audioCapabilitiesReceiver;
// Activity lifecycle
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player_activity);
View root = findViewById(R.id.root);
shutterView = findViewById(R.id.shutter);
debugRootView = findViewById(R.id.controls_root);
videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
surfaceView = (SurfaceView) findViewById(R.id.surface_view);
surfaceView.getHolder().addCallback(this);
debugTextView = (TextView) findViewById(R.id.debug_text_view);
playerStateTextView = (TextView) findViewById(R.id.player_state_view);
subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);
mediaController = new KeyCompatibleMediaController(this);
mediaController.setAnchorView(root);
// retryButton = (Button) findViewById(R.id.retry_button);
// retryButton.setOnClickListener(this);
videoButton = (Button) findViewById(R.id.video_controls);
audioButton = (Button) findViewById(R.id.audio_controls);
textButton = (Button) findViewById(R.id.text_controls);
playPause = (FrameLayout)findViewById(R.id.videoPlayPause);
videoLoad = (FrameLayout) findViewById(R.id.videoLoad);
sb = (SeekBar)findViewById(R.id.seekBar1);
// Guide Info Animator
guideInfo = (FrameLayout)findViewById(R.id.guide_info);
seekBar = (FrameLayout)findViewById(R.id.video_seek);
playPause = (FrameLayout)findViewById(R.id.videoPlayPause);
videoCurrentTime = (TextView)findViewById(R.id.video_timestart);
bitrateTextView=(TextView)findViewById(R.id.bitratetext);
videoTimeEnd = (TextView)findViewById(R.id.video_timeend);
seekBar.setVisibility(View.GONE);
playPause.setVisibility(View.GONE);
root.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
|| keyCode == KeyEvent.KEYCODE_MENU) {
return false;
}
if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
}
return mediaController.dispatchKeyEvent(event);
}
});
CookieHandler currentHandler = CookieHandler.getDefault();
if (currentHandler != defaultCookieManager) {
CookieHandler.setDefault(defaultCookieManager);
}
audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
audioCapabilitiesReceiver.register();
}
@Override
public void onNewIntent(Intent intent) {
releasePlayer();
playerPosition = 0;
setIntent(intent);
}
@Override
public void onResume() {
super.onResume();
Intent intent = getIntent();
Bundle extras = getIntent().getExtras();
contentUri = intent.getData();
contentType = Util.TYPE_HLS;
title = extras.getString("title", title);
description = extras.getString("description", description);
vodimage = extras.getString("vodimage", vodimage);
chimage = extras.getString("chimage", chimage);
datetitle = extras.getString("datetitle", datetitle);
// Set Data
vodTitle = (TextView)findViewById(R.id.vodTitle);
vodTitle.setText(title);
vodDesc = (TextView)findViewById(R.id.vodDesc);
/* DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(player.getMainHandler(), null);
String dfg=bandwidthMeter.getBitrateEstimate()+"";*/
vodDesc.setText(description);
vodThumb = (ImageView)findViewById(R.id.vodThumb);
chLogo = (ImageView)findViewById(R.id.chLogo);
vodTimeDesc = (TextView)findViewById(R.id.vodTimeDesc);
vodTimeDesc.setText(datetitle);
rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setDuration(2000);
rotate.setRepeatCount(Animation.INFINITE);
rotate.setInterpolator(new LinearInterpolator());
rotateLoad= (ImageView) findViewById(R.id.lycaLoadMid_rotate);
loadMid = (ImageView) findViewById(R.id.lycaLoadMid);
rotateLoad.startAnimation(rotate);
videoLoad = (FrameLayout) findViewById(R.id.videoLoad);
//Gathering images
LoadImages loadImage= new LoadImages ();
loadImage.execute(vodimage,chimage);
if (player == null) {
// if (!maybeRequestPermission()) {
preparePlayer(true);
//}
} else {
player.setBackgrounded(false);
}
}
@Override
public void onPause() {
super.onPause();
if (!enableBackgroundAudio) {
releasePlayer();
} else {
player.setBackgrounded(true);
}
shutterView.setVisibility(View.VISIBLE);
}
@Override
public void onDestroy() {
super.onDestroy();
audioCapabilitiesReceiver.unregister();
releasePlayer();
}
// OnClickListener methods
@Override
public void onClick(View view) {
if (view == retryButton) {
preparePlayer(true);
}
}
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
// AudioCapabilitiesReceiver.Listener methods
@Override
public void onAudioCapabilitiesChanged(AudioCapabilities audioCapabilities) {
if (player == null) {
return;
}
boolean backgrounded = player.getBackgrounded();
boolean playWhenReady = player.getPlayWhenReady();
releasePlayer();
preparePlayer(playWhenReady);
player.setBackgrounded(backgrounded);
}
// Permission request listener method
// Internal methods
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case Util.TYPE_SS:
return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(),
new SmoothStreamingTestMediaDrmCallback());
case Util.TYPE_DASH:
return new DashRendererBuilder(this, userAgent, contentUri.toString(),
new WidevineTestMediaDrmCallback(contentId, provider));
case Util.TYPE_HLS:
return new HlsRendererBuilder(this, userAgent, contentUri.toString());
case Util.TYPE_OTHER:
return new ExtractorRendererBuilder(this, userAgent, contentUri);
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
private void preparePlayer(boolean playWhenReady) {
if (player == null) {
player = new DemoPlayer(getRendererBuilder());
player.addListener(this);
player.setCaptionListener(this);
player.setMetadataListener(this);
player.seekTo(playerPosition);
playerNeedsPrepare = true;
mediaController.setMediaPlayer(player.getPlayerControl());
mediaController.setEnabled(true);
eventLogger = new EventLogger();
eventLogger.startSession();
player.addListener(eventLogger);
player.setInfoListener(eventLogger);
player.setInternalErrorListener(eventLogger);
//debugViewHelper = new DebugTextViewHelper(player, debugTextView);
// debugViewHelper.start();
}
if (playerNeedsPrepare) {
player.prepare();
playerNeedsPrepare = false;
updateButtonVisibilities();
}
player.setSurface(surfaceView.getHolder().getSurface());
player.setPlayWhenReady(playWhenReady);
guideInfo.setVisibility(View.VISIBLE);
guideInfo.postDelayed(new Runnable() { public void run() { guideInfo.setVisibility(View.GONE); } }, 5000);
}
private void releasePlayer() {
if (player != null) {
debugViewHelper.stop();
debugViewHelper = null;
playerPosition = player.getCurrentPosition();
player.release();
player = null;
eventLogger.endSession();
eventLogger = null;
}
}
// DemoPlayer.Listener implementation
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
showControls();
}
if (playbackState == ExoPlayer.STATE_BUFFERING) {
if(videoLoad.getVisibility()==View.GONE){
videoLoad.setVisibility(View.VISIBLE);
}
}
if (playbackState == ExoPlayer.STATE_READY) {
videoLoad.setVisibility(View.GONE);
}
if (playbackState == ExoPlayer.STATE_ENDED) {
videoLoad.setVisibility(View.GONE);
finish();
}
if(playWhenReady){
}
String text = "playWhenReady=" + playWhenReady + ", playbackState=";
switch(playbackState) {
case ExoPlayer.STATE_BUFFERING:
text += "buffering";
break;
case ExoPlayer.STATE_ENDED:
text += "ended";
break;
case ExoPlayer.STATE_IDLE:
text += "idle";
break;
case ExoPlayer.STATE_PREPARING:
text += "preparing";
break;
case ExoPlayer.STATE_READY:
text += "ready";
break;
default:
text += "unknown";
break;
}
// playerStateTextView.setText(text);
updateButtonVisibilities();
}
@Override
public void onError(Exception e) {
String errorString = null;
if (e instanceof UnsupportedDrmException) {
// Special case DRM failures.
UnsupportedDrmException unsupportedDrmException = (UnsupportedDrmException) e;
errorString = getString(Util.SDK_INT < 18 ? R.string.error_drm_not_supported
: unsupportedDrmException.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown);
} else if (e instanceof ExoPlaybackException
&& e.getCause() instanceof DecoderInitializationException) {
// Special case for decoder initialization failures.
DecoderInitializationException decoderInitializationException =
(DecoderInitializationException) e.getCause();
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof DecoderQueryException) {
errorString = getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
errorString = getString(R.string.error_no_secure_decoder,
decoderInitializationException.mimeType);
} else {
errorString = getString(R.string.error_no_decoder,
decoderInitializationException.mimeType);
}
}
else {
errorString = getString(R.string.error_instantiating_decoder,
decoderInitializationException.decoderName);
}
}
if (errorString != null) {
Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_LONG).show();
}
playerNeedsPrepare = true;
updateButtonVisibilities();
showControls();
}
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees,
float pixelWidthAspectRatio) {
shutterView.setVisibility(View.GONE);
videoFrame.setAspectRatio(
height == 0 ? 1 : (width * pixelWidthAspectRatio) / height);
}
// User controls
private void updateButtonVisibilities() {
// retryButton.setVisibility(playerNeedsPrepare ? View.VISIBLE : View.GONE);
videoButton.setVisibility(haveTracks(DemoPlayer.TYPE_VIDEO) ? View.VISIBLE : View.GONE);
audioButton.setVisibility(haveTracks(DemoPlayer.TYPE_AUDIO) ? View.VISIBLE : View.GONE);
textButton.setVisibility(haveTracks(DemoPlayer.TYPE_TEXT) ? View.VISIBLE : View.GONE);
}
private boolean haveTracks(int type) {
return player != null && player.getTrackCount(type) > 0;
}
public void showVideoPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
configurePopupWithTracks(popup, null, DemoPlayer.TYPE_VIDEO);
popup.show();
}
public void showAudioPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.enable_background_audio);
final MenuItem backgroundAudioItem = menu.findItem(0);
backgroundAudioItem.setCheckable(true);
backgroundAudioItem.setChecked(enableBackgroundAudio);
OnMenuItemClickListener clickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item == backgroundAudioItem) {
enableBackgroundAudio = !item.isChecked();
return true;
}
return false;
}
};
configurePopupWithTracks(popup, clickListener, DemoPlayer.TYPE_AUDIO);
popup.show();
}
public void showTextPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
configurePopupWithTracks(popup, null, DemoPlayer.TYPE_TEXT);
popup.show();
}
public void showVerboseLogPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose);
menu.setGroupCheckable(Menu.NONE, true, true);
menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true);
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == 0) {
VerboseLogUtil.setEnableAllTags(false);
} else {
VerboseLogUtil.setEnableAllTags(true);
}
return true;
}
});
popup.show();
}
private void configurePopupWithTracks(PopupMenu popup,
final OnMenuItemClickListener customActionClickListener,
final int trackType) {
if (player == null) {
return;
}
int trackCount = player.getTrackCount(trackType);
if (trackCount == 0) {
return;
}
popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return (customActionClickListener != null
&& customActionClickListener.onMenuItemClick(item))
|| onTrackItemClick(item, trackType);
}
});
Menu menu = popup.getMenu();
// ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0).
menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off);
for (int i = 0; i < trackCount; i++) {
menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE,
buildTrackName(player.getTrackFormat(trackType, i)));
}
menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true);
}
private static String buildTrackName(MediaFormat format) {
if (format.adaptive) {
return "auto";
}
String trackName;
if (MimeTypes.isVideo(format.mimeType)) {
trackName = joinWithSeparator(joinWithSeparator(buildResolutionString(format),
buildBitrateString(format)), buildTrackIdString(format));
} else if (MimeTypes.isAudio(format.mimeType)) {
trackName = joinWithSeparator(joinWithSeparator(joinWithSeparator(buildLanguageString(format),
buildAudioPropertyString(format)), buildBitrateString(format)),
buildTrackIdString(format));
} else {
trackName = joinWithSeparator(joinWithSeparator(buildLanguageString(format),
buildBitrateString(format)), buildTrackIdString(format));
}
return trackName.length() == 0 ? "unknown" : trackName;
}
private static String buildResolutionString(MediaFormat format) {
return format.width == MediaFormat.NO_VALUE || format.height == MediaFormat.NO_VALUE
? "" : format.width + "x" + format.height;
}
private static String buildAudioPropertyString(MediaFormat format) {
return format.channelCount == MediaFormat.NO_VALUE || format.sampleRate == MediaFormat.NO_VALUE
? "" : format.channelCount + "ch, " + format.sampleRate + "Hz";
}
private static String buildLanguageString(MediaFormat format) {
return TextUtils.isEmpty(format.language) || "und".equals(format.language) ? ""
: format.language;
}
private static String buildBitrateString(MediaFormat format) {
String s=format.bitrate == MediaFormat.NO_VALUE ? ""
: String.format(Locale.US, "%.2fMbit", format.bitrate / 1000000f);
// Toast.makeText(con, s, Toast.LENGTH_LONG).show();
return s;
}
private static String joinWithSeparator(String first, String second) {
return first.length() == 0 ? second : (second.length() == 0 ? first : first + ", " + second);
}
private static String buildTrackIdString(MediaFormat format) {
return format.trackId == null ? "" : " (" + format.trackId + ")";
}
private boolean onTrackItemClick(MenuItem item, int type) {
if (player == null || item.getGroupId() != MENU_GROUP_TRACKS) {
return false;
}
player.setSelectedTrack(type, item.getItemId() - ID_OFFSET);
return true;
}
private void toggleControlsVisibility() { /*/////////////////////////////////// Showing defalut controllers */
if (mediaController.isShowing()) {
mediaController.hide();
debugRootView.setVisibility(View.GONE);
} else {
showControls();
}
}
private void showControls() {
mediaController.show(0);
debugRootView.setVisibility(View.VISIBLE);
}
// DemoPlayer.CaptionListener implementation
@Override
public void onCues(List<Cue> cues) {
subtitleLayout.setCues(cues);
}
// DemoPlayer.MetadataListener implementation
@Override
public void onId3Metadata(Map<String, Object> metadata) {
for (Map.Entry<String, Object> entry : metadata.entrySet()) {
if (TxxxMetadata.TYPE.equals(entry.getKey())) {
TxxxMetadata txxxMetadata = (TxxxMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: description=%s, value=%s",
TxxxMetadata.TYPE, txxxMetadata.description, txxxMetadata.value));
} else if (PrivMetadata.TYPE.equals(entry.getKey())) {
PrivMetadata privMetadata = (PrivMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: owner=%s",
PrivMetadata.TYPE, privMetadata.owner));
} else if (GeobMetadata.TYPE.equals(entry.getKey())) {
GeobMetadata geobMetadata = (GeobMetadata) entry.getValue();
Log.i(TAG, String.format("ID3 TimedMetadata %s: mimeType=%s, filename=%s, description=%s",
GeobMetadata.TYPE, geobMetadata.mimeType, geobMetadata.filename,
geobMetadata.description));
} else {
Log.i(TAG, String.format("ID3 TimedMetadata %s", entry.getKey()));
}
}
}
// SurfaceHolder.Callback implementation
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (player != null) {
player.setSurface(holder.getSurface());
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
// Do nothing.
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (player != null) {
player.blockingClearSurface();
}
}
private void configureSubtitleView() {
CaptionStyleCompat style;
float fontScale;
if (Util.SDK_INT >= 19) {
style = getUserCaptionStyleV19();
fontScale = getUserCaptionFontScaleV19();
} else {
style = CaptionStyleCompat.DEFAULT;
fontScale = 1.0f;
}
subtitleLayout.setStyle(style);
subtitleLayout.setFractionalTextSize(SubtitleLayout.DEFAULT_TEXT_SIZE_FRACTION * fontScale);
}
@TargetApi(19)
private float getUserCaptionFontScaleV19() {
CaptioningManager captioningManager =
(CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
return captioningManager.getFontScale();
}
@TargetApi(19)
private CaptionStyleCompat getUserCaptionStyleV19() {
CaptioningManager captioningManager =
(CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
return CaptionStyleCompat.createFromCaptionStyle(captioningManager.getUserStyle());
}
/**
* Makes a best guess to infer the type from a media {@link Uri} and an optional overriding file
* extension.
*
* @param uri The {@link Uri} of the media.
* @param fileExtension An overriding file extension.
* @return The inferred type.
*/
private static int inferContentType(Uri uri, String fileExtension) {
String lastPathSegment = !TextUtils.isEmpty(fileExtension) ? "." + fileExtension
: uri.getLastPathSegment();
return Util.inferContentType(lastPathSegment);
}
private static final class KeyCompatibleMediaController extends MediaController {
private MediaController.MediaPlayerControl playerControl;
public KeyCompatibleMediaController(Context context) {
super(context);
}
@Override
public void setMediaPlayer(MediaController.MediaPlayerControl playerControl) {
super.setMediaPlayer(playerControl);
this.playerControl = playerControl;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if (playerControl.canSeekForward() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
playerControl.seekTo(playerControl.getCurrentPosition() + 15000); // milliseconds
BandwidthMeter bm=player.getBandwidthMeter();
Long l=bm.getBitrateEstimate();
storeBitRate=l;
bitrateTextView.setText(storeBitRate+" bits/sec");
show();
}
return true;
} else if (playerControl.canSeekBackward() && keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
playerControl.seekTo(playerControl.getCurrentPosition() - 15000); // milliseconds
show();
}
return true;
}
return super.dispatchKeyEvent(event);
}
}
private class LoadImages extends AsyncTask<String, String, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
//pDialog.setVisibility(View.VISIBLE);
}
protected Void doInBackground(String... args) {
try {
vodImgThumb = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
chImgLogo = BitmapFactory.decodeStream((InputStream)new URL(args[1]).getContent());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void result) {
super.onPostExecute(result);
vodThumb.setImageBitmap(vodImgThumb);
chLogo.setImageBitmap(chImgLogo);
}
}
}
</code></pre>
<p>`</p>
| 0debug |
Angular 2 unit testing - @ViewChild is undefined : <p>I am writing an Angular 2 unit test. I have a <code>@ViewChild</code> subcomponent that I need to recognize after the component initializes. In this case it's a <code>Timepicker</code> component from the ng2-bootstrap library, though the specifics shouldn't matter. After I <code>detectChanges()</code> the subcomponent instance is still undefined.</p>
<p>Pseudo-code:</p>
<pre><code>@Component({
template: `
<form>
<timepicker
#timepickerChild
[(ngModel)]="myDate">
</timepicker>
</form>
`
})
export class ExampleComponent implements OnInit {
@ViewChild('timepickerChild') timepickerChild: TimepickerComponent;
public myDate = new Date();
}
// Spec
describe('Example Test', () => {
let exampleComponent: ExampleComponent;
let fixture: ComponentFixture<ExampleComponent>;
beforeEach(() => {
TestBed.configureTestingModel({
// ... whatever needs to be configured
});
fixture = TestBed.createComponent(ExampleComponent);
});
it('should recognize a timepicker'. async(() => {
fixture.detectChanges();
const timepickerChild: Timepicker = fixture.componentInstance.timepickerChild;
console.log('timepickerChild', timepickerChild)
}));
});
</code></pre>
<p>The pseudo-code works as expected until you reach the console log. The <code>timepickerChild</code> is undefined. Why is this happening?</p>
| 0debug |
Setting up Swagger (ASP.NET Core) using the Authorization headers (Bearer) : <p>I have a Web API (ASP.NET Core) and I am trying to adjust the swagger to make the calls from it.
The calls must contains the Authorization header and I am using Bearer authentication.
The calls from third party apps like Postman, etc. go fine.
But I am having the issue with setting up the headers for swagger (for some reason I don't receive the headers). This is how it looks like now:</p>
<pre><code> "host": "localhost:50352",
"basePath": "/" ,
"schemes": [
"http",
"https"
],
"securityDefinitions": {
"Bearer": {
"name": "Authorization",
"in": "header",
"type": "apiKey",
"description": "HTTP/HTTPS Bearer"
}
},
"paths": {
"/v1/{subAccountId}/test1": {
"post": {
"tags": [
"auth"
],
"operationId": "op1",
"consumes": ["application/json", "application/html"],
"produces": ["application/json", "application/html"],
"parameters": [
{
"name": "subAccountId",
"in": "path",
"required": true,
"type": "string"
}
],
"security":[{
"Bearer": []
}],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "BadRequest",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"500": {
"description": "InternalServerError",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"deprecated": false
}
},
</code></pre>
| 0debug |
connection.query('SELECT * FROM users WHERE username = ' + input_string) | 1threat |
document.location = 'http://evil.com?username=' + user_input; | 1threat |
int qemu_opts_id_wellformed(const char *id)
{
int i;
if (!qemu_isalpha(id[0])) {
return 0;
}
for (i = 1; id[i]; i++) {
if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) {
return 0;
}
}
return 1;
}
| 1threat |
Reshaping from Wide to Long using Year in Variable Name : <p>I am trying to reshape a large dataframe (34645 x 11619) from wide to long. I would like to reshape the years 99 to 16. This means I have variables such as "edu<strong>99</strong>", "edu<strong>00</strong>", ... "edu<strong>16</strong>" or variables such as "p99d<strong>61</strong>", "p<strong>00</strong>d61", ..., "p<strong>16</strong>d61". The year string is not always on the same position.</p>
<p>Is there a way, to tell R to look for the the year strings "99-16" in the variable names when reshaping? (of course given that the string numbers uniquely identify the year).</p>
<p>Or in general, are there efficient strategy to reshape a big dataset?</p>
<p>Thank you so much for your help!</p>
<p>Best, Patrick</p>
| 0debug |
Customising Laravel 5.5 Api Resource Collection pagination : <p>I have been working with laravel api resource. By default laravel provides links and meta as shown below.</p>
<pre><code>"links": {
"first": "https://demo.test/api/v2/taxes?page=1",
"last": "https://demo.test/api/v2/taxes?page=4",
"prev": null,
"next": "https://demo.test/api/v2/taxes?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 4,
"path": "https://demo.test/api/v2/taxes",
"per_page": 2,
"to": 2,
"total": 8
}
</code></pre>
<p>But I don't want this, insted i want something like</p>
<pre><code>"pagination": {
"total": 8,
"count": 8,
"per_page": 25,
"current_page": 1,
"total_pages": 1
}
</code></pre>
<p>I'm able to get this info but if I do <code>return TaxResource::collection($taxes);</code>, I won't get this. Even I have custom collection method </p>
<pre><code> public static function collection($resource)
{
$resource->pagination = [
'total' => $resource->total(),
'count' => $resource->count(),
'per_page' => $resource->perPage(),
'current_page' => $resource->currentPage(),
'total_pages' => $resource->lastPage()
];
return parent::collection($resource);
}
</code></pre>
<p>It is not giving what I want. But if I reference through <code>(TaxResource::collection($taxes))->pagination;</code> I'm able to get that. But I want it to be returned when I do <code>return TaxResource::collection($taxes);</code></p>
| 0debug |
Why is my proogram Written in C not working? Im trying to save integers read by get char to array : I am trying to make a program that will use get char to read three integers and store it in an array but something is wrong in my code. I know this might be simple but I am a beginner so it kind of hard for me. Thanks. So please don't vote down my question.
#include <stdio.h>
int main( )
{
printf("Please enter three digit number 100 to 999: ");
int numEntered[2];
numEntered = getchar();
for (int i = 0; i<3; i++){
printf("%d", numEntered[i])
}
}
| 0debug |
Getting the Value of A Variable from another file C# : I have 2 files and in the 1st file, I have textbox where the user can enter a value. I want to take that value and bring it to the other file. In that program, I have the user entering a value also in a textbox. If the value they enter is higher than the other you get an error.
For example: File 2 ask how many snickers you want to eat and File 1 (ask the user how many snickers we have). If what you want to eat is more than what you have you get an error.
I'm not sure how I can get this value in the other file.
FILE 1:
protected void Page_Load(object sender, EventArgs e)
{
//create string and set it equal to the textbox text
string snickersInventory = txtInventorySnickers.Text;
//create a int and turn the string into an int
int stockSnickers = Int32.Parse(snickersInventory);
}
FILE 2:
protected void btnSubmit_Click(object sender, EventArgs e)
{
//Check to see if the stockSnickers is lower than the amount of Snickers Value
}
| 0debug |
How to find a uppercase elements of array : <p>I have array of letters like this one:</p>
<pre><code>[ 'E', 'v', 'a', 'n', ' ', 'C', 'o', 'l', 'e' ]
</code></pre>
<p>How to take only uppercase elements (in this example it will be 'E' and 'C')</p>
| 0debug |
How do I remove the "Unresolved issue" banner from App Store Connect? : <p>One of my previous builds had a problem that made it through to the Apple Review, which resulted in a banner at the top of the app saying </p>
<blockquote>
<p>There are one or more issues with the following platform(s):</p>
<p>1 unresolved iOS issue</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/op6fF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/op6fF.png" alt="enter image description here"></a></p>
<p>The issue was fixed, a new build was submitted, reviewed, approved and released - yet the banner persists.</p>
<p>How can I make this erroneous and confusing banner go away?</p>
| 0debug |
how to put if statement inside a button's onclicklistener in android : I am working on my major project and I want my button to open different intents based on the string array value obtained. I used if and else if statements inside the onclicklistener of the button but it won't click anymore. Please help me.
This is my XML file:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardCornerRadius="3dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/spacing_large">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/spacing_middle"
android:text="Syllabus"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<Button
android:id="@+id/buttonpdf"
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:text="Open Book" />
</LinearLayout>
<!-- end snippet -->
And this is the java file for the same activity:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
public class ActivityBookDetails extends AppCompatActivity {
public static final String EXTRA_OBJCT = "com.app.sample.recipe.OBJ";
private Book book;
private FloatingActionButton fab;
private View parent_view;
Button button;
String[] obj;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(activity_book_details);
parent_view = findViewById(android.R.id.content);
button = (Button)findViewById(R.id.buttonpdf);
book = (Book) getIntent().getSerializableExtra(EXTRA_OBJCT);
fab = (FloatingActionButton) findViewById(R.id.fab);
fabToggle();
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(book.getName());
((ImageView) findViewById(R.id.image)).setImageResource(book.getPhoto());
LinearLayout subjects = (LinearLayout) findViewById(R.id.subjects);
final String[] title_subjects = getResources().getStringArray(R.array.Subjects);
addIngredientsList(subjects, title_subjects);
obj = title_subjects;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if ("Soft Computing".equals(obj)) {
Intent intent = new Intent(ActivityBookDetails.this, pdfviewactivity.class);
startActivity(intent);
}
else if ("Web Engineering".equals(obj)) {
Intent intent = new Intent(ActivityBookDetails.this, pdfweben.class);
startActivity(intent);
}
else if ("Network Management".equals(obj)) {
Intent intent = new Intent(ActivityBookDetails.this, pdfnetwork.class);
startActivity(intent);
}
else if ("Wireless Network".equals(obj)) {
Intent intent = new Intent(ActivityBookDetails.this, pdfwireless.class);
startActivity(intent);
}
}
});
<!-- end snippet -->
I want my if else condition to work on the basis of the value of string array.
This is a sample java file of one of the given intents:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
public class pdfwireless extends AppCompatActivity {
PDFView pdfView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pdfwireless);
pdfView = (PDFView)findViewById(R.id.pdfView);
pdfView.fromAsset("wirelessnetwork.pdf").load();
}
}
<!-- end snippet -->
| 0debug |
Haskell - Returning list from function : I am trying to create a function which takes in *color* and *number* and returns a list of *Circle* objects (point, radius, color) with changing radius like this:
[Circle point 1*(400/n) col, Circle point 2*(400/n) col, ... , Circle point n*(400/n) col]
Being new to Haskell I am struggling with maps and the concept of adding to a list, but i tried with the following simple approach.
getCircles :: Colour -> Float -> [PictureObject]
getCircles col n = [Circle point (map [1,2..n] * (400/n)) col]
Needless to say, it does not work.
| 0debug |
I need to solve this with arrays in jquery : I have this code and I need to create the following format of array.
var locations = [
['Bondi Beach', -33.890542, 151.274856, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
I have the following ajax petition and I receive all information correctly.
$.ajax({
url: '../get-route/46',
type: 'get',
success: function (data) {
$.each(data.poi, function(key, element) {
console.log(element.name);
console.log(element.latitud);
console.log(element.longitud);
});
}
});
How can I append this inormation into array called localtion ? | 0debug |
SSL/TLS handshake from .NET to APNs - remote certificate is invalid : <p>I'm connecting to <em>Apple Push Notification Service (APNs)</em> from the <em>.NET Framework</em> using a <code>SslStream</code>. I'm connecting using the <code>Binary Provider API</code>. As part of the initial handshake, the <code>SslStream</code> does an <code>AuthenticateAsClient</code> on the network stream. This is the code for that:</p>
<pre><code>_sslStream = new SslStream(_tcpClient.GetStream());
_sslStream.AuthenticateAsClient(_url,
new X509CertificateCollection { _certificate },
SslProtocols.Tls,
true);
</code></pre>
<p>Where <code>_url</code> is the <em>APNs</em> hostname and <code>_certificate</code> the push certificate of the app. On most machines (running a version of Windows Server), this is accepted and communication can continue. However, on some machines, this will fail. This is the exact error:</p>
<pre><code>The remote certificate is invalid according to the validation procedure.
</code></pre>
<p>The code runs as <em>Windows Service</em> under the <em>Local System</em> privileges. When the <strong>exact same code</strong> runs as command-line application under a local user, the <strong>handshake is accepted</strong> and communication can continue. Running the same command-line application under <em>Local System</em> using <code>pexec -i -s</code> causes the same error . I've checked if there are differences in the certificate stores between <em>Local Computer</em> and the <em>Current User</em>, but there are none.</p>
<p>A "workaround" was also tested. In this changed form, the code shown earlier was adapted to completely ignore certificates. This does exactly as you'd expect; the received certificates are not checked and communication can continue. This is what that looks like:</p>
<pre><code>_sslStream = new SslStream(_tcpClient.GetStream(), false, (sender, certificate, chain, errors) => true);
_sslStream.AuthenticateAsClient(_url,
new X509CertificateCollection { _certificate },
SslProtocols.Tls,
false);
</code></pre>
<p>Of course, disabling security is a bad idea. What could be causing the handshake to break?!</p>
| 0debug |
sqlx - non-struct dest type struct with >1 columns (2) : <p>I have searched the error and I have find two questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/24487943/invoke-golang-struct-function-gives-cannot-refer-to-unexported-field-or-method">This one</a>, but my question is not duplicate of it</li>
<li><a href="https://stackoverflow.com/questions/28710974/non-struct-dest-type-struct-with-1-columns">And this one</a>, but there is no answer in this question.</li>
</ul>
<p>Here is my code:</p>
<pre><code>package main
import (
"log"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
var schema = `
CREATE TABLE films (
code int,
name VARCHAR(10)
)`
type Film struct {
code int
name string
}
func main() {
db, err := sqlx.Open("postgres", "user=demas password=root host=192.168.99.100 port=32768 dbname=mydb sslmode=disable")
if err != nil {
log.Fatal(err)
}
db.MustExec(schema)
tx := db.MustBegin()
tx.MustExec("INSERT INTO films(code, name) VALUES($1, $2)", 10, "one")
tx.MustExec("INSERT INTO films(code, name) VALUES($1, $2)", 20, "two")
tx.Commit()
films := []Film{}
err = db.Select(&films, "SELECT * FROM public.films")
if err != nil {
log.Fatal(err)
}
}
</code></pre>
<p>It creates table and insert 2 records, but can not return them back:</p>
<pre><code>λ go run main.go
2016/09/26 14:46:04 non-struct dest type struct with >1 columns (2)
exit status 1
</code></pre>
<p>How can I fix it ?</p>
| 0debug |
i am trying to print a txt file and it doesnt work in @c homework q : i were writing a code that suppose to work on a txt file.
i am writing in java and pyrhon and this my first time using c
so it is a noob q,
i work as i saw in toutorial and in the website
and for some reason my script doent even print my file.
can u tell me what am i doing wrong?
the code will do something far more complex but i still trying to work on my basics
==============
## *my code so far* ##
==============
`int main(int argc, char *argv[]){
/* argv[0] = name of my running file
* argv[1] = the first file that i receive
*/
define MAXBUFLEN 4096
char source[MAXBUFLEN + 1];
int badReturnValue = -1;
char* error = "Error! trying to open the file ";
if(argc != 2)
{
printf("please supply a file \n");
return badReturnValue;
}
char* fileName = argv[1];
if (fopen(argv[1], "r") != NULL)
{
} else{
printf("%s %s", error, fileName);//todo check weather this shit even work
return badReturnValue;
}
FILE *fp = fopen(argv[1], "r"); /* "r" = open for reading */
if (fp != NULL) {
size_t newLen = fread(&source, sizeof(char), MAXBUFLEN, fp);
if ( ferror( fp ) != 0 ) {
printf("%s %s", error, fileName);//todo check weather this shit even work
return badReturnValue;
}
int symbol;
while((symbol = getc(fp)) != EOF){
printf("%c",symbol);
}
printf("finish");
` | 0debug |
QmpInputVisitor *qmp_input_visitor_new(QObject *obj, bool strict)
{
QmpInputVisitor *v;
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.start_struct = qmp_input_start_struct;
v->visitor.end_struct = qmp_input_end_struct;
v->visitor.start_list = qmp_input_start_list;
v->visitor.next_list = qmp_input_next_list;
v->visitor.end_list = qmp_input_end_list;
v->visitor.start_alternate = qmp_input_start_alternate;
v->visitor.type_int64 = qmp_input_type_int64;
v->visitor.type_uint64 = qmp_input_type_uint64;
v->visitor.type_bool = qmp_input_type_bool;
v->visitor.type_str = qmp_input_type_str;
v->visitor.type_number = qmp_input_type_number;
v->visitor.type_any = qmp_input_type_any;
v->visitor.type_null = qmp_input_type_null;
v->visitor.optional = qmp_input_optional;
v->strict = strict;
v->root = obj;
qobject_incref(obj);
return v;
}
| 1threat |
static void rv34_idct_add_c(uint8_t *dst, int stride, DCTELEM *block){
int temp[16];
uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
int i;
rv34_row_transform(temp, block);
memset(block, 0, 16*sizeof(DCTELEM));
for(i = 0; i < 4; i++){
const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
dst[0] = cm[ dst[0] + ( (z0 + z3) >> 10 ) ];
dst[1] = cm[ dst[1] + ( (z1 + z2) >> 10 ) ];
dst[2] = cm[ dst[2] + ( (z1 - z2) >> 10 ) ];
dst[3] = cm[ dst[3] + ( (z0 - z3) >> 10 ) ];
dst += stride;
}
}
| 1threat |
void qemu_map_cache_init(void)
{
unsigned long size;
struct rlimit rlimit_as;
mapcache = qemu_mallocz(sizeof (MapCache));
QTAILQ_INIT(&mapcache->locked_entries);
mapcache->last_address_index = -1;
getrlimit(RLIMIT_AS, &rlimit_as);
rlimit_as.rlim_cur = rlimit_as.rlim_max;
setrlimit(RLIMIT_AS, &rlimit_as);
mapcache->max_mcache_size = rlimit_as.rlim_max;
mapcache->nr_buckets =
(((mapcache->max_mcache_size >> XC_PAGE_SHIFT) +
(1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >>
(MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT));
size = mapcache->nr_buckets * sizeof (MapCacheEntry);
size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);
DPRINTF("qemu_map_cache_init, nr_buckets = %lx size %lu\n", mapcache->nr_buckets, size);
mapcache->entry = qemu_mallocz(size);
}
| 1threat |
static int vmdk_open_vmdk4(BlockDriverState *bs,
BlockDriverState *file,
int flags)
{
int ret;
uint32_t magic;
uint32_t l1_size, l1_entry_sectors;
VMDK4Header header;
VmdkExtent *extent;
int64_t l1_backup_offset = 0;
ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
if (ret < 0) {
return ret;
}
if (header.capacity == 0) {
uint64_t desc_offset = le64_to_cpu(header.desc_offset);
if (desc_offset) {
return vmdk_open_desc_file(bs, flags, desc_offset << 9);
}
}
if (le64_to_cpu(header.gd_offset) == VMDK4_GD_AT_END) {
struct {
struct {
uint64_t val;
uint32_t size;
uint32_t type;
uint8_t pad[512 - 16];
} QEMU_PACKED footer_marker;
uint32_t magic;
VMDK4Header header;
uint8_t pad[512 - 4 - sizeof(VMDK4Header)];
struct {
uint64_t val;
uint32_t size;
uint32_t type;
uint8_t pad[512 - 16];
} QEMU_PACKED eos_marker;
} QEMU_PACKED footer;
ret = bdrv_pread(file,
bs->file->total_sectors * 512 - 1536,
&footer, sizeof(footer));
if (ret < 0) {
return ret;
}
if (be32_to_cpu(footer.magic) != VMDK4_MAGIC ||
le32_to_cpu(footer.footer_marker.size) != 0 ||
le32_to_cpu(footer.footer_marker.type) != MARKER_FOOTER ||
le64_to_cpu(footer.eos_marker.val) != 0 ||
le32_to_cpu(footer.eos_marker.size) != 0 ||
le32_to_cpu(footer.eos_marker.type) != MARKER_END_OF_STREAM)
{
return -EINVAL;
}
header = footer.header;
}
if (le32_to_cpu(header.version) >= 3) {
char buf[64];
snprintf(buf, sizeof(buf), "VMDK version %d",
le32_to_cpu(header.version));
qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bs->device_name, "vmdk", buf);
return -ENOTSUP;
}
l1_entry_sectors = le32_to_cpu(header.num_gtes_per_gte)
* le64_to_cpu(header.granularity);
if (l1_entry_sectors == 0) {
return -EINVAL;
}
l1_size = (le64_to_cpu(header.capacity) + l1_entry_sectors - 1)
/ l1_entry_sectors;
if (le32_to_cpu(header.flags) & VMDK4_FLAG_RGD) {
l1_backup_offset = le64_to_cpu(header.rgd_offset) << 9;
}
extent = vmdk_add_extent(bs, file, false,
le64_to_cpu(header.capacity),
le64_to_cpu(header.gd_offset) << 9,
l1_backup_offset,
l1_size,
le32_to_cpu(header.num_gtes_per_gte),
le64_to_cpu(header.granularity));
extent->compressed =
le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
extent->has_marker = le32_to_cpu(header.flags) & VMDK4_FLAG_MARKER;
extent->version = le32_to_cpu(header.version);
extent->has_zero_grain = le32_to_cpu(header.flags) & VMDK4_FLAG_ZERO_GRAIN;
ret = vmdk_init_tables(bs, extent);
if (ret) {
vmdk_free_last_extent(bs);
}
return ret;
}
| 1threat |
Using Skin for Libgdx in AIDE [Android IDE] : Ok, Hi everyone,
I'm kinda new, it's my first post here.. and I started some time ago to develop a game,
I'm still struggeling to make something to work
Stuck in a simple task, loading a Libgdx Skin, I already tried several methods,
such as
Skin skin = new Skin(Gdx.files.internal("....json"),
also tried using atlas and more with the corresponding files but my app refuses to work and still crashes when it comes to skin loading, for now I removed the skin part and came here to ask for an help,
If needed I'll post my code below, or edit this, thanks in advance for any help you could give,
In short story: How to properly load a libgdx skin on AIDE android app? It keeps crashing my app :/ | 0debug |
Can anyone help me with this one? : I am having a hard time trying to solve this one particular Big Oh problem:
4n log n+7n=O(n log n)
I have tried by applying n>=1 but nothing's coming out of it and the only hint is that 4n log n dominates 7n | 0debug |
static int convert_do_copy(ImgConvertState *s)
{
uint8_t *buf = NULL;
int64_t sector_num, allocated_done;
int ret;
int n;
s->has_zero_init = s->min_sparse && !s->target_has_backing
? bdrv_has_zero_init(blk_bs(s->target))
: false;
if (!s->has_zero_init && !s->target_has_backing &&
bdrv_can_write_zeroes_with_unmap(blk_bs(s->target)))
{
ret = bdrv_make_zero(blk_bs(s->target), BDRV_REQ_MAY_UNMAP);
if (ret == 0) {
s->has_zero_init = true;
}
}
if (s->compressed) {
if (s->cluster_sectors <= 0 || s->cluster_sectors > s->buf_sectors) {
error_report("invalid cluster size");
ret = -EINVAL;
goto fail;
}
s->buf_sectors = s->cluster_sectors;
}
buf = blk_blockalign(s->target, s->buf_sectors * BDRV_SECTOR_SIZE);
s->allocated_sectors = 0;
sector_num = 0;
while (sector_num < s->total_sectors) {
n = convert_iteration_sectors(s, sector_num);
if (n < 0) {
ret = n;
goto fail;
}
if (s->status == BLK_DATA) {
s->allocated_sectors += n;
}
sector_num += n;
}
s->src_cur = 0;
s->src_cur_offset = 0;
s->sector_next_status = 0;
sector_num = 0;
allocated_done = 0;
while (sector_num < s->total_sectors) {
n = convert_iteration_sectors(s, sector_num);
if (n < 0) {
ret = n;
goto fail;
}
if (s->status == BLK_DATA) {
allocated_done += n;
qemu_progress_print(100.0 * allocated_done / s->allocated_sectors,
0);
}
ret = convert_read(s, sector_num, n, buf);
if (ret < 0) {
error_report("error while reading sector %" PRId64
": %s", sector_num, strerror(-ret));
goto fail;
}
ret = convert_write(s, sector_num, n, buf);
if (ret < 0) {
error_report("error while writing sector %" PRId64
": %s", sector_num, strerror(-ret));
goto fail;
}
sector_num += n;
}
if (s->compressed) {
ret = blk_write_compressed(s->target, 0, NULL, 0);
if (ret < 0) {
goto fail;
}
}
ret = 0;
fail:
qemu_vfree(buf);
return ret;
}
| 1threat |
Playing with null and zero values in javscript : Hi I have a variable which can hold value as zero or null.
Ex:-
var temp = 0;
if(temp){ // if temp is zero do some work if null go in else
// Do some work
} else {
}
How i can check this without using temp === 0 as 0 is false.
Any suggestions ? | 0debug |
change select value when press button : <p>i'm still Beginner at this
i have table and i select data between two date range using this code and its working fine for me</p>
<pre><code>$StartDate = "2016-01-01";
$EndDate = "2016-12-30";
$result = mysql_query("SELECT *FROM users where submit_date BETWEEN '$StartDate' AND '$EndDate'") or die(mysql_error());
</code></pre>
<p>then i added 2 data picker and button</p>
<pre><code>echo "<form method=post action=><table>".
"<tr><td>Start Date : </td><td><input type=date name=StartDate value=$StartDate></td></tr>".
"<tr><td>End Date : </td><td><input type=date name=EndDate value=$EndDate></td></tr>".
"<tr><td colspan=2><input type=submit name=UpdateSelect value=Set></td></tr>".
"</table></form>";
</code></pre>
<p>now i need help with this
how to update the page when i press the sumbit button
to start selecting from the new start date and end date.</p>
<p>i'm sorry for my bad english.
and thanks</p>
| 0debug |
My java bank program is throwing a nut point exception and i can't figure out why : <p>the exception
Exception in thread "main" java.lang.NullPointerException
at HW3.Bank.createNewCustomer(Bank.java:28)
at HW3.Bank.main(Bank.java:56)"
is on the line
MyCustomers[NumofCustomers].openAccount(MyFirstName, MyLastName, openingBalence);" </p>
<p>and the line
"MyBank.createNewCustomer();"</p>
<pre><code>package HW3;
public class Customer {
private String FirstName;
private String LastName;
private Account MyAccount;
public void openAccount(String MyFirstname, String MyLastname, float OpeningBalence)
{
MyAccount = new Account();
if(MyAccount == null);
{
FirstName = MyFirstname;
LastName= MyLastname;
MyAccount.setMinimumBalence(100);
MyAccount.setOverdraftFee(45);
MyAccount.depositFunds(OpeningBalence);
}
}
public void closeAccount()
{
MyAccount = null;
}
public void depositFunds(float Funds)
{
MyAccount.depositFunds(Funds);
}
public void withdrawFunds(float Funds)
{
MyAccount.withdrawFunds(Funds);
}
public float getBalence()
{
return MyAccount.getBalence();
}
public void printAccountInfo()
{
MyAccount.printAccountInfo();
}
public String getFirstName()
{
return FirstName;
}
public String getLastName()
{
return LastName;
}
public String getAccountNumber()
{
return MyAccount.getAccountNumber();
}
}package HW3;
public class Account {
private String AccountNumber;
private float Balence;
private float minimumBalence;
private float overdraftFee;
public float getBalence()
{
return Balence;
}
public void depositFunds(float Funds)
{
Balence += Funds;
}
public void withdrawFunds(float Funds)
{
Balence -= Funds;
if (Balence<minimumBalence)
{
Balence -= overdraftFee;
}
}
public void printAccountInfo()
{
System.out.println("Account number: " + AccountNumber);
System.out.println("Account Balence: " + Balence);
System.out.println("Minnimum ballence: " + minimumBalence);
System.out.println("Account Over draft fee: " + overdraftFee);
}
public String getAccountNumber()
{
return AccountNumber;
}
public void setMinimumBalence(float MinBalence)
{
minimumBalence = MinBalence;
}
public void setOverdraftFee(float OverDraft)
{
overdraftFee = OverDraft;
}
}
package HW3;
import java.util.Scanner;
public class Bank {
private String RoutingNumber;
private int NumofCustomers;
private Customer[] MyCustomers;
public Bank()
{
this.MyCustomers = new Customer[100];
NumofCustomers = 0;
}
public void createNewCustomer()
{
String MyFirstName;
String MyLastName;
float openingBalence;
Scanner userInputScanner = new Scanner(System.in);
System.out.println("What is your first name? ");
MyFirstName = userInputScanner.nextLine();
System.out.println("What is your last name? ");
MyLastName = userInputScanner.nextLine();
System.out.println("What is your opening balence? ");
openingBalence = userInputScanner.nextFloat();
MyCustomers[NumofCustomers].openAccount(MyFirstName, MyLastName, openingBalence);
}
public int FindCustomer(String MyFirstName, String MyLastName)
{
for(int i = 0; i< NumofCustomers; i++)
{
if((MyCustomers[i].getFirstName() == MyFirstName) && (MyCustomers[i].getLastName()== MyLastName))
{
return i;
}
}
return -1;
}
public int FindCustomer(String AccountNum)
{
for(int i = 0; i< NumofCustomers; i++)
{
if(MyCustomers[i].getAccountNumber() == AccountNum)
{
return i;
}
}
return -1;
}
public static void main(String args[]) // main function that initiates the helpers
{
Bank MyBank = new Bank();
MyBank.createNewCustomer();
int index = MyBank.FindCustomer("Bijan", "Azodi" );
if(index >= 0)
{
MyBank.MyCustomers[index].depositFunds(1000);
MyBank.MyCustomers[index].printAccountInfo();
MyBank.MyCustomers[index].withdrawFunds(500);
MyBank.MyCustomers[index].withdrawFunds(601);
}
else
{
System.out.print("The customer was not found in this bank");
}
}
}
</code></pre>
| 0debug |
static int pci_nic_uninit(PCIDevice *dev)
{
PCIEEPRO100State *d = DO_UPCAST(PCIEEPRO100State, dev, dev);
EEPRO100State *s = &d->eepro100;
cpu_unregister_io_memory(s->mmio_index);
return 0;
}
| 1threat |
static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
int pix_fmt, int w, int h)
{
UINT8 *buf, *src, *dest;
int size, j, i;
size = avpicture_get_size(pix_fmt, w, h);
buf = malloc(size);
if (!buf)
return;
switch(pix_fmt) {
case PIX_FMT_YUV420P:
dest = buf;
for(i=0;i<3;i++) {
if (i == 1) {
w >>= 1;
h >>= 1;
}
src = picture->data[i];
for(j=0;j<h;j++) {
memcpy(dest, src, w);
dest += w;
src += picture->linesize[i];
}
}
break;
case PIX_FMT_YUV422P:
size = (w * h) * 2;
buf = malloc(size);
dest = buf;
for(i=0;i<3;i++) {
if (i == 1) {
w >>= 1;
}
src = picture->data[i];
for(j=0;j<h;j++) {
memcpy(dest, src, w);
dest += w;
src += picture->linesize[i];
}
}
break;
case PIX_FMT_YUV444P:
size = (w * h) * 3;
buf = malloc(size);
dest = buf;
for(i=0;i<3;i++) {
src = picture->data[i];
for(j=0;j<h;j++) {
memcpy(dest, src, w);
dest += w;
src += picture->linesize[i];
}
}
break;
case PIX_FMT_YUV422:
size = (w * h) * 2;
buf = malloc(size);
dest = buf;
src = picture->data[0];
for(j=0;j<h;j++) {
memcpy(dest, src, w * 2);
dest += w * 2;
src += picture->linesize[0];
}
break;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
size = (w * h) * 3;
buf = malloc(size);
dest = buf;
src = picture->data[0];
for(j=0;j<h;j++) {
memcpy(dest, src, w * 3);
dest += w * 3;
src += picture->linesize[0];
}
break;
default:
return;
}
s->format->write_packet(s, index, buf, size);
free(buf);
}
| 1threat |
static int ppc_hash64_pp_check(int key, int pp, bool nx)
{
int access;
access = 0;
if (key == 0) {
switch (pp) {
case 0x0:
case 0x1:
case 0x2:
access |= PAGE_WRITE;
case 0x3:
case 0x6:
access |= PAGE_READ;
break;
}
} else {
switch (pp) {
case 0x0:
case 0x6:
access = 0;
break;
case 0x1:
case 0x3:
access = PAGE_READ;
break;
case 0x2:
access = PAGE_READ | PAGE_WRITE;
break;
}
}
if (!nx) {
access |= PAGE_EXEC;
}
return access;
}
| 1threat |
Flutter: How would one save a Canvas/CustomPainter to an image file? : <p>I am trying to collect a signature from the user and save it to an image. I have made it far enough that I can draw on the screen, but now I'd like to click a button to save to an image and store in my database.</p>
<p>This is what I have so far:</p>
<pre><code>import 'package:flutter/material.dart';
class SignaturePadPage extends StatefulWidget {
SignaturePadPage({Key key}) : super(key: key);
@override
_SignaturePadPage createState() => new _SignaturePadPage();
}
class _SignaturePadPage extends State<SignaturePadPage> {
List<Offset> _points = <Offset>[];
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: GestureDetector(
onPanUpdate: (DragUpdateDetails details) {
setState(() {
RenderBox referenceBox = context.findRenderObject();
Offset localPosition =
referenceBox.globalToLocal(details.globalPosition);
_points = new List.from(_points)..add(localPosition);
});
},
onPanEnd: (DragEndDetails details) => _points.add(null),
child: new CustomPaint(painter: new SignaturePainter(_points)),
),
);
}
}
class SignaturePainter extends CustomPainter {
SignaturePainter(this.points);
final List<Offset> points;
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..color = Colors.black
..strokeCap = StrokeCap.round
..strokeWidth = 5.0;
for (int i = 0; i < points.length - 1; i++) {
if (points[i] != null && points[i + 1] != null)
canvas.drawLine(points[i], points[i + 1], paint);
}
}
bool shouldRepaint(SignaturePainter other) => other.points != points;
}
</code></pre>
<p>Not sure where to go from there...</p>
| 0debug |
static always_inline void gen_sradi (DisasContext *ctx, int n)
{
int sh = SH(ctx->opcode) + (n << 5);
if (sh != 0) {
int l1, l2;
TCGv t0;
l1 = gen_new_label();
l2 = gen_new_label();
tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rS(ctx->opcode)], 0, l1);
t0 = tcg_temp_new(TCG_TYPE_TL);
tcg_gen_andi_tl(t0, cpu_gpr[rS(ctx->opcode)], (1ULL << sh) - 1);
tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1);
tcg_gen_ori_tl(cpu_xer, cpu_xer, 1 << XER_CA);
tcg_gen_br(l2);
gen_set_label(l1);
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));
gen_set_label(l2);
tcg_gen_sari_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)], sh);
} else {
tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_gpr[rS(ctx->opcode)]);
tcg_gen_andi_tl(cpu_xer, cpu_xer, ~(1 << XER_CA));
}
if (unlikely(Rc(ctx->opcode) != 0))
gen_set_Rc0(ctx, cpu_gpr[rA(ctx->opcode)]);
}
| 1threat |
how to print * like a alphabet letters : I used this for char D
I also made some methods for the output of I,H
for(int i = 1; i <= 4; i++) {
for(int j = 1; j <= 4; j++) {
if(i == 1 || i == 4) {
System.out.print("*");
} else if(j == 1 || j == 4) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
now I need a output like this.
*
* *
* * * *
* *
| 0debug |
Xcode have two buttons open two different view controllers : I am having trouble with this code:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var team1Field: UITextField!
@IBAction func rules(_ sender: Any)
{
performSegue(withIdentifier: "rulesegue", sender: self)
}
@IBAction func start(_ sender: Any)
{
if team1Field.text != ""
{
performSegue(withIdentifier: "segue", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
let secondController = segue.destination as! SecondViewController
secondController.team1String = team1Field.text!
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
please keep in mind I am a beginner so you might need to dumb it down for me.
I have a "home screen" and on that screen I have a text input for the user to enter their team name. then two buttons "start" and "rules"
Start goes to SecondViewController and I am trying to get "rules" to open rulesViewController by executing "rulesegue"
on this line of code I am getting the following error: "Thread 1: signal SIGABRT"
let secondController = segue.destination as! SecondViewController
not sure why :/ | 0debug |
static int swf_write_video(AVFormatContext *s,
AVCodecContext *enc, const uint8_t *buf, int size)
{
SWFContext *swf = s->priv_data;
ByteIOContext *pb = &s->pb;
int c = 0;
int outSize = 0;
int outSamples = 0;
if ( swf->swf_frame_number >= 16000 ) {
return 0;
}
if ( enc->codec_type == CODEC_TYPE_VIDEO ) {
SWFFrame *new_frame = av_malloc(sizeof(SWFFrame));
new_frame->prev = 0;
new_frame->next = swf->frame_head;
new_frame->data = av_malloc(size);
new_frame->size = size;
memcpy(new_frame->data,buf,size);
swf->frame_head = new_frame;
if ( swf->frame_tail == 0 ) {
swf->frame_tail = new_frame;
}
}
if ( swf->audio_type ) {
retry_swf_audio_packet:
if ( ( swf->audio_size-outSize ) >= 4 ) {
int mp3FrameSize = 0;
int mp3SampleRate = 0;
int mp3IsMono = 0;
int mp3SamplesPerFrame = 0;
uint8_t header[4];
for (c=0; c<4; c++) {
header[c] = swf->audio_fifo[(swf->audio_in_pos+outSize+c) % AUDIO_FIFO_SIZE];
}
if ( swf_mp3_info(header,&mp3FrameSize,&mp3SamplesPerFrame,&mp3SampleRate,&mp3IsMono) ) {
if ( ( swf->audio_size-outSize ) >= mp3FrameSize ) {
outSize += mp3FrameSize;
outSamples += mp3SamplesPerFrame;
if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) {
goto retry_swf_audio_packet;
}
}
} else {
swf->audio_in_pos ++;
swf->audio_size --;
swf->audio_in_pos %= AUDIO_FIFO_SIZE;
goto retry_swf_audio_packet;
}
}
if ( ( swf->sound_samples + outSamples + swf->samples_per_frame ) < swf->video_samples ) {
return 0;
}
if ( enc->codec_type == CODEC_TYPE_VIDEO ) {
swf->skip_samples = (int)( ( (double)(swf->swf_frame_number) * (double)enc->frame_rate_base * 44100. ) / (double)(enc->frame_rate) );
swf->skip_samples -= swf->video_samples;
}
}
if (swf->skip_samples <= ( swf->samples_per_frame / 2 ) ) {
if ( swf->frame_tail ) {
if ( swf->video_type == CODEC_ID_FLV1 ) {
if ( swf->video_frame_number == 0 ) {
put_swf_tag(s, TAG_VIDEOSTREAM);
put_le16(pb, VIDEO_ID);
put_le16(pb, 15000 );
put_le16(pb, enc->width);
put_le16(pb, enc->height);
put_byte(pb, 0);
put_byte(pb, SWF_VIDEO_CODEC_FLV1);
put_swf_end_tag(s);
put_swf_tag(s, TAG_PLACEOBJECT2);
put_byte(pb, 0x36);
put_le16(pb, 1);
put_le16(pb, VIDEO_ID);
put_swf_matrix(pb, 1 << FRAC_BITS, 0, 0, 1 << FRAC_BITS, 0, 0);
put_le16(pb, swf->video_frame_number );
put_byte(pb, 'v');
put_byte(pb, 'i');
put_byte(pb, 'd');
put_byte(pb, 'e');
put_byte(pb, 'o');
put_byte(pb, 0x00);
put_swf_end_tag(s);
} else {
put_swf_tag(s, TAG_PLACEOBJECT2);
put_byte(pb, 0x11);
put_le16(pb, 1);
put_le16(pb, swf->video_frame_number );
put_swf_end_tag(s);
}
for (; ( enc->frame_number - swf->video_frame_number ) > 0;) {
put_swf_tag(s, TAG_VIDEOFRAME | TAG_LONG);
put_le16(pb, VIDEO_ID);
put_le16(pb, swf->video_frame_number++ );
put_buffer(pb, swf->frame_tail->data, swf->frame_tail->size);
put_swf_end_tag(s);
}
} else if ( swf->video_type == CODEC_ID_MJPEG ) {
if (swf->swf_frame_number > 0) {
put_swf_tag(s, TAG_REMOVEOBJECT);
put_le16(pb, SHAPE_ID);
put_le16(pb, 1);
put_swf_end_tag(s);
put_swf_tag(s, TAG_FREECHARACTER);
put_le16(pb, BITMAP_ID);
put_swf_end_tag(s);
}
put_swf_tag(s, TAG_JPEG2 | TAG_LONG);
put_le16(pb, BITMAP_ID);
put_byte(pb, 0xff);
put_byte(pb, 0xd8);
put_byte(pb, 0xff);
put_byte(pb, 0xd9);
put_buffer(pb, swf->frame_tail->data, swf->frame_tail->size);
put_swf_end_tag(s);
put_swf_tag(s, TAG_PLACEOBJECT);
put_le16(pb, SHAPE_ID);
put_le16(pb, 1);
put_swf_matrix(pb, 20 << FRAC_BITS, 0, 0, 20 << FRAC_BITS, 0, 0);
put_swf_end_tag(s);
} else {
}
av_free(swf->frame_tail->data);
swf->frame_tail = swf->frame_tail->prev;
if ( swf->frame_tail ) {
if ( swf->frame_tail->next ) {
av_free(swf->frame_tail->next);
}
swf->frame_tail->next = 0;
} else {
swf->frame_head = 0;
}
swf->swf_frame_number ++;
}
}
swf->video_samples += swf->samples_per_frame;
if ( outSize > 0 ) {
put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
put_le16(pb, outSamples);
put_le16(pb, 0);
for (c=0; c<outSize; c++) {
put_byte(pb,swf->audio_fifo[(swf->audio_in_pos+c) % AUDIO_FIFO_SIZE]);
}
put_swf_end_tag(s);
swf->sound_samples += outSamples;
swf->audio_in_pos += outSize;
swf->audio_size -= outSize;
swf->audio_in_pos %= AUDIO_FIFO_SIZE;
}
put_swf_tag(s, TAG_SHOWFRAME);
put_swf_end_tag(s);
put_flush_packet(&s->pb);
return 0;
}
| 1threat |
How to parse JSON with datestamp outside object into each object, and create an array : <p>Server returns JSON data, I would like to insert the datestamp before each nested object into each object, then delete the datestamp outside of each object. </p>
<p>Then, I would like to put all inner objects inside of an array.</p>
<p>Is there a way to do this with JSON.parse or otherwise?</p>
<p>Thank-you</p>
<p>This is what the JSON data looks like after it's parsed:</p>
<pre><code>{ '2019-09-30 16:00:00':
{ '1. apples': '13',
'2. oranges': '12',
'3. peaches': '15',
'4. cherries': '14',
'5. onions': '43' },
'2019-09-30 15:59:00':
{ '1. apples': '42',
'2. oranges': '43',
'3. peaches': '34',
'4. cherries': '64',
'5. onions': '45' },
}
</code></pre>
<p>This is what I would like it to look like after moving the datestamps into each trailing object, and wrapping all objects into an array. The actual data is many thousands of objects:</p>
<pre><code>{ [ { 'date': '2019-09-30 16:00:00',
'1. apples': '13',
'2. oranges': '12',
'3. peaches': '15',
'4. cherries': '14',
'5. onions': '43' },
{ 'date': '2019-09-30 15:59:00'
'1. apples': '42',
'2. oranges': '43',
'3. peaches': '34',
'4. cherries': '64',
'5. onions': '45' },
] }
</code></pre>
<p>I hope to get it looking like the second set of data. Thank-you</p>
| 0debug |
Install pandas in a Dockerfile : <p>I am trying to create a Docker image.
The Dockerfile is the following:</p>
<pre><code># Use the official Python 3.6.5 image
FROM python:3.6.5-alpine3.7
# Set the working directory to /app
WORKDIR /app
# Get the
COPY requirements.txt /app
RUN pip3 install --no-cache-dir -r requirements.txt
# Configuring access to Jupyter
RUN mkdir /notebooks
RUN jupyter notebook --no-browser --ip 0.0.0.0 --port 8888 /notebooks
</code></pre>
<p>The requirements.txt file is:</p>
<pre><code>jupyter
numpy==1.14.3
pandas==0.23.0rc2
scipy==1.0.1
scikit-learn==0.19.1
pillow==5.1.1
matplotlib==2.2.2
seaborn==0.8.1
</code></pre>
<p>Running the command <code>docker build -t standard .</code> gives me an error when docker it trying to install pandas.
The error is the following:</p>
<pre><code>Collecting pandas==0.23.0rc2 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/46/5c/a883712dad8484ef907a2f42992b122acf2bcecbb5c2aa751d1033908502/pandas-0.23.0rc2.tar.gz (12.5MB)
Complete output from command python setup.py egg_info:
/bin/sh: svnversion: not found
/bin/sh: svnversion: not found
non-existing path in 'numpy/distutils': 'site.cfg'
Could not locate executable gfortran
... (loads of other stuff)
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xb6f6a5o/pandas/
The command '/bin/sh -c pip3 install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
</code></pre>
<p>When I try to install a lower version of pandas==0.22.0, I get this error:</p>
<pre><code>Step 5/7 : RUN pip3 install --no-cache-dir -r requirements.txt
---> Running in 5810ea896689
Collecting jupyter (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting numpy==1.14.3 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/b0/2b/497c2bb7c660b2606d4a96e2035e92554429e139c6c71cdff67af66b58d2/numpy-1.14.3.zip (4.9MB)
Collecting pandas==0.22.0 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/08/01/803834bc8a4e708aedebb133095a88a4dad9f45bbaf5ad777d2bea543c7e/pandas-0.22.0.tar.gz (11.3MB)
Could not find a version that satisfies the requirement Cython (from versions: )
No matching distribution found for Cython
The command '/bin/sh -c pip3 install --no-cache-dir -r requirements.txt' returned a non-zero code: 1
</code></pre>
<p>I also tried to install Cyphon and setuptools before pandas, but it gave the same <code>No matching distribution found for Cython</code> error at the pip3 install pandas line.</p>
<p>How could I get pandas installed.</p>
| 0debug |
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS - Python 3.x & OS X : <p>I am trying to install Python 3.5.1 according to these instructions: </p>
<p><a href="http://thomas-cokelaer.info/blog/2014/08/installing-another-python-version-into-virtualenv/" rel="noreferrer">http://thomas-cokelaer.info/blog/2014/08/installing-another-python-version-into-virtualenv/</a> </p>
<p>I have: OS X 10.11.3, no Homebrew. Xcode is installed. Xcode Command Line Tools are installed. </p>
<p>Everything goes well until <code>make install</code> has run for a while. Then it quits with this:</p>
<pre><code>if test "xupgrade" != "xno" ; then \
case upgrade in \
upgrade) ensurepip="--upgrade" ;; \
install|*) ensurepip="" ;; \
esac; \
./python.exe -E -m ensurepip \
$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
</code></pre>
<p>I have been searching for a long time and all I can find are instructions for Homebrew or for Apache or other servers. I understand that I've got to get SSL/TLS on my system, but I've had no luck.</p>
<p>The biggest reason I don't want Homebrew is that I want non-CS students to follow the same procedure, and I don't want them to install Homebrew. </p>
| 0debug |
BS4 web scraping is not returning anything. : My code:
res=requests.get('https://www.flickr.com/photos/')
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')
linkItem = soup.select('div.photo-list-photo-interaction
a[ref^=/photos]')
print(linkItem)
is not returning any values.
After Inspecting element, the photos are inside a <div class "photo-list-photo-interaction">. So above soup.select should worked. But it doesn't.
any ideas?.
Thank you
| 0debug |
having real trouble in this app ; : <p>i Created this app but after adding the marks showing feature .....</p>
<p>even with a lot of work i am not able to debug it </p>
<p>They are not letting me post as there is mostly code (
Google Terms of Service
Last modified: October 25, 2017 (view archived versions)</p>
<p>Welcome to Google!
Thanks for using our products and services (“Services”). The Services are provided by Google LLC (“Google”), located at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.</p>
<p>By using our Services, you are agreeing to these terms. Please read them carefully.</p>
<p>Our Services are very diverse, so sometimes additional terms or product requirements (including age requirements) may apply. Additional terms will be available with the relevant Services, and those additional terms become part of your agreement with us if you use those Services.)</p>
<pre><code>package com.example.user.questions;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Arrays;
import static android.widget.Toast.makeText;
import static com.example.user.questions.R.string.your_answer;
public class MainActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
private TextView mQuestionTextView;
private Button mNextButton;
private static final String TAG = "QuizActivity";
private static final String KEY_INDEX = "index";
private int marksObtained = 0;
private TextView mShowAnswers;
//array for question
private Question[] mQuestionBank = new Question[]
{
new Question( R.string.question_inc , true ) ,
new Question( R.string.question_nda , true ),
new Question( R.string.question_sex , false )
};
private int mCurrentIndex = 0 ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
mTrueButton = findViewById( R.id.true_button );
mFalseButton = findViewById( R.id.false_button );
mNextButton = findViewById( R.id.next_button );
mQuestionTextView = findViewById( R.id.questions_text );
mShowAnswers = findViewById( R.id.show_result );
//using nezt button here cause it should implement before setting text og question
updateQuestion();
mNextButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length ;
updateQuestion();
showAnswers( mCurrentIndex );
}
} );
mTrueButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAnswers( true );
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length ;
updateQuestion();
showAnswers( mCurrentIndex );
}
} );
mFalseButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
checkAnswers( false );
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length ;
updateQuestion();
showAnswers( mCurrentIndex );
}
} );
}
private void updateQuestion() {
int questions = mQuestionBank[mCurrentIndex].getTextResId();
mQuestionTextView.setText( questions ); }
private void checkAnswers (boolean mUserPressedTrue){
boolean answerIsTrue = mQuestionBank[mCurrentIndex].isAnswerTrue();
int messageResId = 0;
if (answerIsTrue == mUserPressedTrue) {
messageResId = R.string.correct_toast;
marksObtained = marksObtained + 1 ;
} else {
messageResId = R.string.wrong_toast;
}
Toast.makeText( this , messageResId , Toast.LENGTH_SHORT ).show();
}
@Override
public void onSaveInstanceState (Bundle savedInstanceState){
super.onSaveInstanceState( savedInstanceState );
savedInstanceState.putInt( KEY_INDEX , mCurrentIndex );
}
public void showAnswers (int var){
if (var == 2) mShowAnswers.setText( marksObtained );
}
}
</code></pre>
<p><a href="https://i.stack.imgur.com/melY9.png" rel="nofollow noreferrer">log cat while i click last "next_button" hit</a></p>
| 0debug |
void arm_sysctl_init(uint32_t base, uint32_t sys_id)
{
arm_sysctl_state *s;
int iomemtype;
s = (arm_sysctl_state *)qemu_mallocz(sizeof(arm_sysctl_state));
if (!s)
return;
s->base = base;
s->sys_id = sys_id;
iomemtype = cpu_register_io_memory(0, arm_sysctl_readfn,
arm_sysctl_writefn, s);
cpu_register_physical_memory(base, 0x00000fff, iomemtype);
}
| 1threat |
change <audio> src with javascript, for all browser : <p>this change src with javascript it's only working well on Chrome, but it does not work on other browsers, what am I missing ??</p>
<p><a href="https://stackoverflow.com/questions/10792163/change-audio-src-with-javascript">change <audio> src with javascript</a></p>
| 0debug |
Where can I complain about Google Store target API level restrictions : <p>Google recently announced that they are going to start restricting publishing Android apps that do not target recent API level versions. I support this change, but I need some special case exceptions, and have not found an appropriate forum to request those. I know that this is not it, but hope someone here can point me where I should go.</p>
<p>I publish an app that has been out for a long time and still has a significant number of users running it under Gingerbread. It also uses a number of support libraries, and the recent versions of those libraries, the ones targeting the latest API levels, no longer support Gingerbread devices. The end result is that I can not build and apk that supports API level 9 if it targets an SDK level greater than 23. Which is not going to be accepted come November.</p>
<p>I did have a plan to address this issue. That was to start distributing two apk files for each update. One that targets the latest API level and has a min API of probably 21. The other will support older devices and will have a target and max API of 20 and a min API of 9. The problem is that the older target API apk will not be accepted by the Play Store unless I can convince someone that they should continue to accept any app where the target and max API levels are the same.</p>
| 0debug |
Add class to a tag within a string : A little background. I am loading the content from a wordpress site into an app programmed in framework7. Due to this all external links break because they need to contain class="link external". I am looking for a way to allow users to click the links and open a browser window. The only way I could think of is some type of `preg_replace` that can identify if there are any links in the content string. I just cant think of a way to check if it already has a class and add to it or add the class attribute if it does not exist. | 0debug |
Get birthday with a query : <p>I have problems to get age of certain dates.</p>
<pre><code>SELECT birthday, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(birthday)), '%Y')+0 AS age FROM users;
</code></pre>
<p>The result is:</p>
<pre><code>| 27-07-1955 | NULL |
</code></pre>
<p>What's wrong in this select?</p>
| 0debug |
static void virt_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
mc->init = machvirt_init;
mc->max_cpus = MAX_CPUMASK_BITS;
mc->has_dynamic_sysbus = true;
mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1;
mc->pci_allow_0_address = true;
}
| 1threat |
Android Studio code not working - help please : I am Mario and I am new as an android developer. Let's say I am moving my very first steps on it.
I wrote a code using Android Studio IDE that should ask for a couple of numbers and give us an answer for the ratio between them.
I receive the error saying "error class interface or enum expected". I read around that it occurs when I open too many curve brackets without closing them or vice-versa but I have just 2 open brackets and then 2 closed ones so it seems balanced.
I wrote it in java. Do not take me wrong but I read there are no android programming languages, you just use Java for it right?
The code is as follow (I also copy paste some comments related to every line I used):
Import java.util.Scanner;
//I am importing the package Scanner that will have some specific features for the keyboard. In java we use "." to denote the hierarchy. So it will denote java util Scanner in Windows environment. The full meaning is import Scanner class which is in util folder inside the java folder. In java util stands for utility and contains utility classes, Scanner is a predefined class for taking inputs from the user;
Class BIL{
//I am defining a class, a function;
Public static void main(string args[]){
//I am defining the main of the class here. Public is an access specifier which allows the main method to be accessble everywhere. Static helps main method to get loaded without getting alled by any instance/object. If the main method were not declared static than JVM has to create an instance of main class Void clarifies that the main method will not return any value. Main is the name of the method. String[] args defines a string array to pass arguments sent from command line. args is the variable name of the String array and can be changed to anything.It helps to send argument in the form of an array by knowing their locations;
Scanner userInput = new Scanner(System.in);
//I create an object of a Scanner class which is defined in import java.util.scanner package. Scanner class allows user to take input from keyboard. System.in passed as parameter will tell to the compiler that input will be provided through keyboard. System.in is the standard input;
Double MH, c, Md;
//I define variable with double-precision 64-bit floating point;
System.out.println(Enter the load, please:);
//It prints the argument passed, into the System.out which is the standard output. In this particular case it prints it and goes to a new line;
MH = userInput.nextDouble();
//The call to .nextDouble() waits for a value to be input. Once input, the value will be stored in the assigned variable MH20;
System.out.println(Enter capacity, please:);
c = userInput.nextDouble();
Md = MH/c;
System.out.println(The mass needed is:);
System.out.println(Md);
//it prints out the result;
}
}
Many thanks.
Mario
| 0debug |
static void add_entry(TiffEncoderContext * s,
enum TiffTags tag, enum TiffTypes type, int count,
const void *ptr_val)
{
uint8_t *entries_ptr = s->entries + 12 * s->num_entries;
av_assert0(s->num_entries < TIFF_MAX_ENTRY);
bytestream_put_le16(&entries_ptr, tag);
bytestream_put_le16(&entries_ptr, type);
bytestream_put_le32(&entries_ptr, count);
if (type_sizes[type] * count <= 4) {
tnput(&entries_ptr, count, ptr_val, type, 0);
} else {
bytestream_put_le32(&entries_ptr, *s->buf - s->buf_start);
check_size(s, count * type_sizes2[type]);
tnput(s->buf, count, ptr_val, type, 0);
}
s->num_entries++;
}
| 1threat |
Anyone knows of a good tutorial on using gtk2+ with opengl? : I am writing a C program that makes use of fixed pipeline opengl and freeglut. However, I would like to use a complete toolkit like GTK+ instead of freeglut. I cannot use GTK3+ as it is not compatible with old opengl code, so I would like to use gtk2+. Howver I cannot find any tutorials on combining gtk2+ with opengl. Anyone knows of any good tutorials on gtk2+ plus old opengl? | 0debug |
static int spapr_vio_check_reg(VIOsPAPRDevice *sdev, VIOsPAPRDeviceInfo *info)
{
VIOsPAPRDevice *other_sdev;
DeviceState *qdev;
VIOsPAPRBus *sbus;
sbus = DO_UPCAST(VIOsPAPRBus, bus, sdev->qdev.parent_bus);
QTAILQ_FOREACH(qdev, &sbus->bus.children, sibling) {
other_sdev = DO_UPCAST(VIOsPAPRDevice, qdev, qdev);
if (other_sdev != sdev && other_sdev->reg == sdev->reg) {
fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n",
info->qdev.name, other_sdev->qdev.info->name, sdev->reg);
return -EEXIST;
}
}
return 0;
}
| 1threat |
C++ Expression Must Have A Class Type error : I am writing a disjoint set class in c++ and I keep getting this error: Expression must have a class type
The class looks like this:
class DisjointSet{
private:
int *array;
int size;
public:
void make_set(int elements){
array = new int[elements];
for (int i = 0; i < array.length; i++) {
array[i] = i;
size += 1;
}
}
and the error comes up when i try to get array.length in the for loop. I tried using the -> operator instead but I'm not sure why this is an issue... | 0debug |
How to group consecutive elements values based on the key value in python 3? : I'm a python beginner and need help on this.
My input is
input: [(5, 1), (0, 3), (1, 3), (2, 3), (3, 3), (4, 3), (6, 3)]
input contains [(value,key)]
My output should be
0,1,2
3,4,6
5
The consecutive values need be grouped based on the key count and then sorted to show the final output ..
ie) 5 appears once and should be grouped alone
0, 1, 2 has the key count as 3 and hence should be grouped together
3,4,6 has the key count as 3 and hence should be grouped together
The final output should be in sorted order and look like this
0,1,2
3,4,6
5
I tried with grouby itertools and it only groups the values based on similar keys.
Any solutions would be helpful. | 0debug |
Using for loop to make multiple drawLine shapes : <p>I am making a star using a draw line. I want to run a for loop to expand a star into multiple stars in a grid-like pattern. I am fairly new to java and could use some help with my code. The gride pattern that I would like the stars to open up too isn't too specific as far as columns x rows go. even making 6 stars or 9 stars is fine, as long as they are in a grid-like pattern. </p>
<p>So far, I have the star drawn with drawLine. At one point I got two stars but they were to close to each other. When I run the code it looks like I have a whole bunch of stars sort of staggered on top of each other and being able to get two stars on Star Field, I would like to get more in such 5x6 pattern or something close. I believe I might be having a hard time computing the math in the for loops to get this to happen.</p>
<p>Should I run, multiple nested for loops or is there a way to do this with using a minimal amount of for loops?</p>
<pre><code>public static void drawFlag(int stars, int stripes, java.awt.Graphics
g, int x, int y, int width, int height) {
// Sets backround rectangle color to white
g.setColor(Color.WHITE);
g.fillRect(x, y, width, height);
// Draw filled red rectangles *stripes*
int stripeHeight = height/stripes;
g.setColor(Color.RED);
int lastStripeDrawnY = 0;
// For loop runs red stripes
for (int i = y; i < y + height - 2*stripeHeight; i = i + 2*stripeHeight)
{
g.fillRect(x, i, width, stripeHeight);
lastStripeDrawnY = i;
}
// expands strips across the rectangle
int lastStripeY = lastStripeDrawnY+2*stripeHeight;
int lastStripeHeight = y + height - lastStripeY;
if (stripes%2 != 0) {
g.fillRect(x, lastStripeY, width, lastStripeHeight);
}
int stars1 = 15;
for (int cols = 1; cols <= stars1; cols++) {
int rows = stars1/cols;
if (cols > rows && cols <2*rows && cols*rows == stars1) {
}
}
// Draws the starField
int numberOfRedStripes = (int)Math.ceil(stripes/2.0);
int starFieldHeight = numberOfRedStripes*stripeHeight;
int starFieldWidth = starFieldHeight*width/height;
g.setColor(Color.BLUE);
g.fillRect(x, y, starFieldWidth, starFieldHeight);
for (int x1 = 0; x1+100 <+ starFieldWidth-5; x1++) {
if(x1/5*4 == stars) {
drawStar(g,x1,y,50);
for(int y1 = 0; y1 <=starFieldHeight-5;y1++) {
if(y1/4*2 == stars) {
drawStar(g,x,y1,50);
}
}
}
}
}
// drawLine the star
public static void drawStar(java.awt.Graphics g, int x, int y, int size)
{
g.setColor(Color.WHITE);
g.drawLine(x+size/2, y+size/6, x+4*size/5, y+5*size/6);
g.drawLine(x+4*size/5,y+5*size/6, x+size/6, y+2*size/5);
g.drawLine(x+size/6, y+2*size/5, x+5*size/6, y+2*size/5);
g.drawLine(x+5*size/6, y+2*size/5, x+size/5, y+5*size/6);
g.drawLine(x+size/5, y+5*size/6, x+size/2, y+size/6);
}
}
</code></pre>
<p>Expand one star into a checkered grid-like pattern.</p>
| 0debug |
static inline void idct(int16_t *block)
{
int64_t __attribute__((aligned(8))) align_tmp[16];
int16_t * const temp= (int16_t*)align_tmp;
asm volatile(
#if 0
#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
"pmaddwd %%mm2, %%mm7 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq 56(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm0, %%mm1 \n\t" \
"paddd %%mm0, %%mm0 \n\t" \
"psubd %%mm1, %%mm0 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm5, %%mm7 \n\t" \
"movq 72(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm5 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm1, %%mm2 \n\t" \
"paddd %%mm5, %%mm1 \n\t" \
"psubd %%mm5, %%mm2 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm7 \n\t" \
"packssdw %%mm4, %%mm2 \n\t" \
"movq %%mm7, " #dst " \n\t"\
"movq " #src1 ", %%mm1 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"movq %%mm2, 24+" #dst " \n\t"\
"pmaddwd %%mm1, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm0, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm0 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm1, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm6, %%mm2 \n\t" \
"movq %%mm2, 8+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" \
"movq %%mm4, 16+" #dst " \n\t"\
#define COL_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
#rounder ", %%mm0 \n\t"\
"pmaddwd %%mm2, %%mm7 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"movq 56(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm1, %%mm7 \n\t" \
"movq 72(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm1 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm2 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm2 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm7, %%mm7 \n\t" \
"movd %%mm7, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"movd %%mm2, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq " #src1 ", %%mm0 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm0 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm5, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm5 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm0, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm2, 32+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"\
#define DC_COND_ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq "MANGLE(wm1010)", %%mm4 \n\t"\
"pand %%mm0, %%mm4 \n\t"\
"por %%mm1, %%mm4 \n\t"\
"por %%mm2, %%mm4 \n\t"\
"por %%mm3, %%mm4 \n\t"\
"packssdw %%mm4,%%mm4 \n\t"\
"movd %%mm4, %%eax \n\t"\
"orl %%eax, %%eax \n\t"\
"jz 1f \n\t"\
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
"pmaddwd %%mm2, %%mm7 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq 56(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm0, %%mm1 \n\t" \
"paddd %%mm0, %%mm0 \n\t" \
"psubd %%mm1, %%mm0 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm5, %%mm7 \n\t" \
"movq 72(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm5 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm1, %%mm2 \n\t" \
"paddd %%mm5, %%mm1 \n\t" \
"psubd %%mm5, %%mm2 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm7 \n\t" \
"packssdw %%mm4, %%mm2 \n\t" \
"movq %%mm7, " #dst " \n\t"\
"movq " #src1 ", %%mm1 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"movq %%mm2, 24+" #dst " \n\t"\
"pmaddwd %%mm1, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm0, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm0 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm1, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm6, %%mm2 \n\t" \
"movq %%mm2, 8+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" \
"movq %%mm4, 16+" #dst " \n\t"\
"jmp 2f \n\t"\
"1: \n\t"\
"pslld $16, %%mm0 \n\t"\
"#paddd "MANGLE(d40000)", %%mm0 \n\t"\
"psrad $13, %%mm0 \n\t"\
"packssdw %%mm0, %%mm0 \n\t"\
"movq %%mm0, " #dst " \n\t"\
"movq %%mm0, 8+" #dst " \n\t"\
"movq %%mm0, 16+" #dst " \n\t"\
"movq %%mm0, 24+" #dst " \n\t"\
"2: \n\t"
ROW_IDCT( (%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
DC_COND_ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11)
DC_COND_ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11)
DC_COND_ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11)
COL_IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
COL_IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
COL_IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
COL_IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
#else
#define DC_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq "MANGLE(wm1010)", %%mm4 \n\t"\
"pand %%mm0, %%mm4 \n\t"\
"por %%mm1, %%mm4 \n\t"\
"por %%mm2, %%mm4 \n\t"\
"por %%mm3, %%mm4 \n\t"\
"packssdw %%mm4,%%mm4 \n\t"\
"movd %%mm4, %%eax \n\t"\
"orl %%eax, %%eax \n\t"\
"jz 1f \n\t"\
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
"pmaddwd %%mm2, %%mm7 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq 56(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm0, %%mm1 \n\t" \
"paddd %%mm0, %%mm0 \n\t" \
"psubd %%mm1, %%mm0 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm5, %%mm7 \n\t" \
"movq 72(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm5 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm1, %%mm2 \n\t" \
"paddd %%mm5, %%mm1 \n\t" \
"psubd %%mm5, %%mm2 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm7 \n\t" \
"packssdw %%mm4, %%mm2 \n\t" \
"movq %%mm7, " #dst " \n\t"\
"movq " #src1 ", %%mm1 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"movq %%mm2, 24+" #dst " \n\t"\
"pmaddwd %%mm1, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm0, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm0 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm1, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm6, %%mm2 \n\t" \
"movq %%mm2, 8+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" \
"movq %%mm4, 16+" #dst " \n\t"\
"jmp 2f \n\t"\
"1: \n\t"\
"pslld $16, %%mm0 \n\t"\
"paddd "MANGLE(d40000)", %%mm0 \n\t"\
"psrad $13, %%mm0 \n\t"\
"packssdw %%mm0, %%mm0 \n\t"\
"movq %%mm0, " #dst " \n\t"\
"movq %%mm0, 8+" #dst " \n\t"\
"movq %%mm0, 16+" #dst " \n\t"\
"movq %%mm0, 24+" #dst " \n\t"\
"2: \n\t"
#define Z_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift, bt) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq %%mm0, %%mm4 \n\t"\
"por %%mm1, %%mm4 \n\t"\
"por %%mm2, %%mm4 \n\t"\
"por %%mm3, %%mm4 \n\t"\
"packssdw %%mm4,%%mm4 \n\t"\
"movd %%mm4, %%eax \n\t"\
"orl %%eax, %%eax \n\t"\
"jz " #bt " \n\t"\
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
"pmaddwd %%mm2, %%mm7 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq 56(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm0, %%mm1 \n\t" \
"paddd %%mm0, %%mm0 \n\t" \
"psubd %%mm1, %%mm0 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm5, %%mm7 \n\t" \
"movq 72(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm5 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm1, %%mm2 \n\t" \
"paddd %%mm5, %%mm1 \n\t" \
"psubd %%mm5, %%mm2 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm7 \n\t" \
"packssdw %%mm4, %%mm2 \n\t" \
"movq %%mm7, " #dst " \n\t"\
"movq " #src1 ", %%mm1 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"movq %%mm2, 24+" #dst " \n\t"\
"pmaddwd %%mm1, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm0, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm0 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm1, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm6, %%mm2 \n\t" \
"movq %%mm2, 8+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" \
"movq %%mm4, 16+" #dst " \n\t"\
#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
"pmaddwd %%mm2, %%mm7 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq 56(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm0, %%mm1 \n\t" \
"paddd %%mm0, %%mm0 \n\t" \
"psubd %%mm1, %%mm0 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm5, %%mm7 \n\t" \
"movq 72(%2), %%mm5 \n\t" \
"pmaddwd %%mm3, %%mm5 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm5 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm1, %%mm2 \n\t" \
"paddd %%mm5, %%mm1 \n\t" \
"psubd %%mm5, %%mm2 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm7 \n\t" \
"packssdw %%mm4, %%mm2 \n\t" \
"movq %%mm7, " #dst " \n\t"\
"movq " #src1 ", %%mm1 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"movq %%mm2, 24+" #dst " \n\t"\
"pmaddwd %%mm1, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm0, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm0 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm1, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm6, %%mm2 \n\t" \
"movq %%mm2, 8+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm0, %%mm4 \n\t" \
"movq %%mm4, 16+" #dst " \n\t"\
DC_COND_IDCT( 0(%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
Z_COND_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11, 4f)
Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 2f)
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 1f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
#rounder ", %%mm0 \n\t"\
"pmaddwd %%mm2, %%mm7 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"movq 56(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm1, %%mm7 \n\t" \
"movq 72(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm1 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm2 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm2 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm7, %%mm7 \n\t" \
"movd %%mm7, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"movd %%mm2, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq " #src1 ", %%mm0 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm0 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm5, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm5 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm0, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm2, 32+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"4: \n\t"
Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 6f)
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 5f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
#rounder ", %%mm0 \n\t"\
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"movq 56(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"movq 72(%2), %%mm7 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"paddd %%mm4, %%mm1 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm1, %%mm4 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm2 \n\t" \
"paddd %%mm7, %%mm0 \n\t" \
"psubd %%mm7, %%mm2 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"movd %%mm1, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"movd %%mm2, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq 88(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"movq %%mm5, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm1, %%mm2 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm1 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm1 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm1 \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm2, 32+" #dst " \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm1, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"6: \n\t"
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 7f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
#rounder ", %%mm0 \n\t"\
"movq %%mm0, %%mm5 \n\t" \
"movq 56(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"movq 72(%2), %%mm7 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"paddd %%mm4, %%mm1 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm1, %%mm4 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm2 \n\t" \
"paddd %%mm7, %%mm0 \n\t" \
"psubd %%mm7, %%mm2 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"movd %%mm1, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"movd %%mm2, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq 88(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"movq %%mm5, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm1, %%mm2 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm1 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm1 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm1 \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm2, 32+" #dst " \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm1, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"2: \n\t"
Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 3f)
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq " #src5 ", %%mm3 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
#rounder ", %%mm0 \n\t"\
"pmaddwd %%mm2, %%mm7 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"movq 56(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"pmaddwd 64(%2), %%mm2 \n\t" \
"paddd %%mm1, %%mm7 \n\t" \
"movq 72(%2), %%mm1 \n\t" \
"pmaddwd %%mm3, %%mm1 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"paddd %%mm2, %%mm1 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm2 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm2 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm7, %%mm7 \n\t" \
"movd %%mm7, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"movd %%mm2, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq " #src1 ", %%mm0 \n\t" \
"movq 80(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 88(%2), %%mm7 \n\t" \
"pmaddwd 96(%2), %%mm0 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"movq %%mm5, %%mm2 \n\t" \
"pmaddwd 104(%2), %%mm3 \n\t" \
"paddd %%mm7, %%mm4 \n\t" \
"paddd %%mm4, %%mm2 \n\t" \
"psubd %%mm4, %%mm5 \n\t" \
"psrad $" #shift ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm0, %%mm3 \n\t" \
"paddd %%mm3, %%mm6 \n\t" \
"psubd %%mm3, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm2, %%mm2 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm2, 32+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"3: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
#rounder ", %%mm0 \n\t"\
"pmaddwd %%mm2, %%mm7 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"movq 64(%2), %%mm3 \n\t"\
"pmaddwd %%mm2, %%mm3 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm1 \n\t" \
"paddd %%mm3, %%mm0 \n\t" \
"psubd %%mm3, %%mm1 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm1 \n\t"\
"packssdw %%mm7, %%mm7 \n\t" \
"movd %%mm7, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"movd %%mm1, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq 80(%2), %%mm4 \n\t" \
"pmaddwd %%mm2, %%mm4 \n\t" \
"pmaddwd 96(%2), %%mm2 \n\t" \
"movq %%mm5, %%mm1 \n\t" \
"paddd %%mm4, %%mm1 \n\t" \
"psubd %%mm4, %%mm5 \n\t" \
"psrad $" #shift ", %%mm1 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm2, %%mm6 \n\t" \
"psubd %%mm2, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm1, %%mm1 \n\t" \
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm1, 32+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"5: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
#rounder ", %%mm0 \n\t"\
"psubd %%mm5, %%mm6 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"movq 8+" #src0 ", %%mm2 \n\t" \
"movq 8+" #src4 ", %%mm3 \n\t" \
"movq 16(%2), %%mm1 \n\t" \
"pmaddwd %%mm2, %%mm1 \n\t" \
"movq 24(%2), %%mm7 \n\t" \
"pmaddwd %%mm7, %%mm2 \n\t" \
"movq 32(%2), %%mm7 \n\t" \
"pmaddwd %%mm3, %%mm7 \n\t" \
"pmaddwd 40(%2), %%mm3 \n\t" \
#rounder ", %%mm1 \n\t"\
"paddd %%mm1, %%mm7 \n\t" \
"paddd %%mm1, %%mm1 \n\t" \
#rounder ", %%mm2 \n\t"\
"psubd %%mm7, %%mm1 \n\t" \
"paddd %%mm2, %%mm3 \n\t" \
"paddd %%mm2, %%mm2 \n\t" \
"psubd %%mm3, %%mm2 \n\t" \
"psrad $" #shift ", %%mm4 \n\t"\
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm3 \n\t"\
"packssdw %%mm7, %%mm4 \n\t" \
"movq %%mm4, " #dst " \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"packssdw %%mm3, %%mm0 \n\t" \
"movq %%mm0, 16+" #dst " \n\t"\
"movq %%mm0, 96+" #dst " \n\t"\
"movq %%mm4, 112+" #dst " \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"psrad $" #shift ", %%mm6 \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm2, %%mm5 \n\t" \
"movq %%mm5, 32+" #dst " \n\t"\
"psrad $" #shift ", %%mm1 \n\t"\
"packssdw %%mm1, %%mm6 \n\t" \
"movq %%mm6, 48+" #dst " \n\t"\
"movq %%mm6, 64+" #dst " \n\t"\
"movq %%mm5, 80+" #dst " \n\t"
IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"\
"1: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq " #src4 ", %%mm1 \n\t" \
"movq " #src1 ", %%mm2 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
"movq 32(%2), %%mm5 \n\t" \
"pmaddwd %%mm1, %%mm5 \n\t" \
"movq 40(%2), %%mm6 \n\t" \
"pmaddwd %%mm6, %%mm1 \n\t" \
#rounder ", %%mm4 \n\t"\
"movq %%mm4, %%mm6 \n\t" \
"movq 48(%2), %%mm7 \n\t" \
#rounder ", %%mm0 \n\t"\
"pmaddwd %%mm2, %%mm7 \n\t" \
"paddd %%mm5, %%mm4 \n\t" \
"psubd %%mm5, %%mm6 \n\t" \
"movq %%mm0, %%mm5 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm5 \n\t" \
"movq 64(%2), %%mm1 \n\t"\
"pmaddwd %%mm2, %%mm1 \n\t" \
"paddd %%mm4, %%mm7 \n\t" \
"paddd %%mm4, %%mm4 \n\t" \
"psubd %%mm7, %%mm4 \n\t" \
"psrad $" #shift ", %%mm7 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"movq %%mm0, %%mm3 \n\t" \
"paddd %%mm1, %%mm0 \n\t" \
"psubd %%mm1, %%mm3 \n\t" \
"psrad $" #shift ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm3 \n\t"\
"packssdw %%mm7, %%mm7 \n\t" \
"movd %%mm7, " #dst " \n\t"\
"packssdw %%mm0, %%mm0 \n\t" \
"movd %%mm0, 16+" #dst " \n\t"\
"packssdw %%mm3, %%mm3 \n\t" \
"movd %%mm3, 96+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"movd %%mm4, 112+" #dst " \n\t"\
"movq 80(%2), %%mm4 \n\t" \
"pmaddwd %%mm2, %%mm4 \n\t" \
"pmaddwd 96(%2), %%mm2 \n\t" \
"movq %%mm5, %%mm3 \n\t" \
"paddd %%mm4, %%mm3 \n\t" \
"psubd %%mm4, %%mm5 \n\t" \
"psrad $" #shift ", %%mm3 \n\t"\
"psrad $" #shift ", %%mm5 \n\t"\
"movq %%mm6, %%mm4 \n\t" \
"paddd %%mm2, %%mm6 \n\t" \
"psubd %%mm2, %%mm4 \n\t" \
"psrad $" #shift ", %%mm6 \n\t"\
"packssdw %%mm3, %%mm3 \n\t" \
"movd %%mm3, 32+" #dst " \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"packssdw %%mm6, %%mm6 \n\t" \
"movd %%mm6, 48+" #dst " \n\t"\
"packssdw %%mm4, %%mm4 \n\t" \
"packssdw %%mm5, %%mm5 \n\t" \
"movd %%mm4, 64+" #dst " \n\t"\
"movd %%mm5, 80+" #dst " \n\t"
IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0),/nop, 20)
"jmp 9f \n\t"
"#.balign 16 \n\t"
"7: \n\t"
#undef IDCT
#define IDCT(src0, src4, src1, src5, dst, rounder, shift) \
"movq " #src0 ", %%mm0 \n\t" \
"movq 16(%2), %%mm4 \n\t" \
"pmaddwd %%mm0, %%mm4 \n\t" \
"movq 24(%2), %%mm5 \n\t" \
"pmaddwd %%mm5, %%mm0 \n\t" \
#rounder ", %%mm4 \n\t"\
#rounder ", %%mm0 \n\t"\
"psrad $" #shift ", %%mm4 \n\t"\
"psrad $" #shift ", %%mm0 \n\t"\
"movq 8+" #src0 ", %%mm2 \n\t" \
"movq 16(%2), %%mm1 \n\t" \
"pmaddwd %%mm2, %%mm1 \n\t" \
"movq 24(%2), %%mm7 \n\t" \
"pmaddwd %%mm7, %%mm2 \n\t" \
"movq 32(%2), %%mm7 \n\t" \
#rounder ", %%mm1 \n\t"\
#rounder ", %%mm2 \n\t"\
"psrad $" #shift ", %%mm1 \n\t"\
"packssdw %%mm1, %%mm4 \n\t" \
"movq %%mm4, " #dst " \n\t"\
"psrad $" #shift ", %%mm2 \n\t"\
"packssdw %%mm2, %%mm0 \n\t" \
"movq %%mm0, 16+" #dst " \n\t"\
"movq %%mm0, 96+" #dst " \n\t"\
"movq %%mm4, 112+" #dst " \n\t"\
"movq %%mm0, 32+" #dst " \n\t"\
"movq %%mm4, 48+" #dst " \n\t"\
"movq %%mm4, 64+" #dst " \n\t"\
"movq %%mm0, 80+" #dst " \n\t"
IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0),/nop, 20)
IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0),/nop, 20)
#endif
"9: \n\t"
:: "r" (block), "r" (temp), "r" (coeffs)
: "%eax"
);
}
| 1threat |
hwo can i run a "DELETE FROM TABLE" with jdbc in spark 2.4? : i'm using a code like this
spark.read.format("jdbc").options(Map("url" -> "jdbc:url"))
i need to use a DELETE FROM | 0debug |
struct omap_gpmc_s *omap_gpmc_init(struct omap_mpu_state_s *mpu,
hwaddr base,
qemu_irq irq, qemu_irq drq)
{
int cs;
struct omap_gpmc_s *s = (struct omap_gpmc_s *)
g_malloc0(sizeof(struct omap_gpmc_s));
memory_region_init_io(&s->iomem, NULL, &omap_gpmc_ops, s, "omap-gpmc", 0x1000);
memory_region_add_subregion(get_system_memory(), base, &s->iomem);
s->irq = irq;
s->drq = drq;
s->accept_256 = cpu_is_omap3630(mpu);
s->revision = cpu_class_omap3(mpu) ? 0x50 : 0x20;
s->lastirq = 0;
omap_gpmc_reset(s);
for (cs = 0; cs < 8; cs++) {
memory_region_init_io(&s->cs_file[cs].nandiomem, NULL,
&omap_nand_ops,
&s->cs_file[cs],
"omap-nand",
256 * 1024 * 1024);
}
memory_region_init_io(&s->prefetch.iomem, NULL, &omap_prefetch_ops, s,
"omap-gpmc-prefetch", 256 * 1024 * 1024);
return s;
}
| 1threat |
Solving a simple equation from Visual Studio Command Line Arguments : I want to solve a simple equation like "3X = 5" on Visual Studio C# framework.
The command line arguments must be given in the form "calc 3X = 6" and the output must be - *argument* and output as "X = 2". I am lost, can someone direct me on how I can go about it?
Thanks! | 0debug |
In R is it better to use integer64, numeric, or character for large integer id numbers? : <p>I am working with a dataset that has several columns that represent integer ID numbers (e.g. transactionId and accountId). These ID numbers are are often 12 digits long, which makes them too large to store as a 32 bit integer.</p>
<p>What's the best approach in a situation like this?</p>
<ol>
<li>Read the ID in as a character string. </li>
<li>Read the ID as a integer64 using the bit64 package. </li>
<li>Read the ID as a numeric (i.e. double). </li>
</ol>
<p>I have been warned about the dangers of testing equality with doubles, but I'm not sure if that will be a problem in the context of using them as IDs, where I might merge and filter based on them, but never do arithmetic on the ID numbers.</p>
<p>Character strings seems intuitively like it should be slower to test for equality and do merges, but maybe in practice it doesn't make much of a difference.</p>
| 0debug |
I'm getting type error and I'm not sure why. Please help me correct this : (https://i.stack.imgur.com/00ckA.png)
Python 2.5
Not sure what's going wrong. I've tried this a million different ways and I am so confused. Please be nice as I'm a bit of a beginner at Python.
import math
quad_function = "(a * x^2) + b * x + c"
print "A quadratic function is:" + quad_function
a_input = raw_input("Is 'a' given?")
b_input = raw_input("Is 'b' given?")
c_input = raw_input("Is 'c' given?")
x_input = raw_input("Are any of the solutions given?")
if a_input == "yes":
a = int(raw_input("What is 'a'?"))
if b_input == "yes":
b = int(raw_input("What is 'b'?"))
if c_input == "yes":
c = int(raw_input("What is 'c'?"))
if x_input == "one":
x_1 = int(raw_input("What is the first solution?"))
if x_input == "both":
x_1 = int(raw_input("What is the first solution"))
x_2 = int(raw_input("What is the second solution"))
print 'The quadratic function is:' + str(a) + 'x^2' + '+' + str(b) + 'x' + "+" + str(c)
d = b ** 2 - 4*a*c
if d > 1:
num_roots = 2
if d == 1:
num_roots = 1
if d < 1:
num_roots = 0
print "There are " + str(num_roots) + " roots"
if x_input == "no" and d > 2 and a_input == 'yes' and b_input == 'yes' and c_input == 'yes':
x1 = float(((-b) + math.sqrt(d))/(2*a))
x2 = float(((-b) - math.sqrt(d))/(2*a))
print "The two solutions are: " + str(x1) * "and " + str(x2) | 0debug |
Why doesn't the find() method work in this scenario? : <p>Contents of file2.txt:</p>
<pre><code>zalgoalpha
beta
</code></pre>
<p>My code:</p>
<pre><code>file = open("file2.txt", "r", encoding = "utf-8")
print(file.read())
print(file.read().find("beta"))
</code></pre>
<p>Why does the second print convey "-1" ("beta" doesn't exist), even though it's right in the file, at index 11?</p>
| 0debug |
Excel: Highlight cell based on another cell : I don't know if this would be possible so I am going to ask. If a value in column D changes (Column D contains wage rates) then highlight in that same row cell K Column K has a formula based on column D.
For example if D4 is updated with new wage rate then highlight K4.
Thank you in advanced for your help.
| 0debug |
Error in console: ng.probe is not a function : <p>Yesterday i update ng cli and core to 8.0.0v. After that successfully init a new app and run it. Once when app was build and served on localhost:4200 i open the console and there was a error: ng.probe is not a function</p>
<p>I tryed to research the issue but there was no relevant info about it.</p>
<p>Actual result:
After ng serve / npm start there is a issue in console: Uncaught TypeError: ng.probe is not a function.
<a href="https://user-images.githubusercontent.com/32274987/58589676-14960b80-826b-11e9-8c6d-adb1f141cef7.png" rel="noreferrer">Current console state</a>
<a href="https://user-images.githubusercontent.com/32274987/58589626-ff20e180-826a-11e9-8c0c-3f88aaefad6b.png" rel="noreferrer">Current angular state</a></p>
<p>Expected result:
No error in console</p>
| 0debug |
Is there a general function or way in Java to calculate an equation of the form (a+b+...+n)^2 with a,b,n >= 0? : <p>I need to find a way to implement an algorithm in Java that can calculate (a+b+...+n)^2 with a,b,n >= 0. The purpose is to use it afterwards in order to calculate Jain's Fairness index for my algorithm in networks. Is there any standard way to do that or any specific library for advanced math that i might have missed?</p>
| 0debug |
How to make a Calendar with notification system by using Swift? : <p>My project is about a calendar system. When the manager writes his worker's off days. The app will show all workers's off days on the Calendar and has to remind the manager 2 weeks before off day. And all infos will be on database. I am pretty new to swift and ios. SQLite, NSCalendar..? Dont sure how to start. Some help would be great. </p>
| 0debug |
Get correct image orientation by Google Cloud Vision api (TEXT_DETECTION) : <p>I tried Google Cloud Vision api (TEXT_DETECTION) on 90 degrees rotated image. It still can return recognized text correctly. (see image below)</p>
<p>That means the engine can recognize text even the image is 90, 180, 270 degrees rotated.</p>
<p>However the response result doesn't include information of correct image orientation. (document: <a href="https://developers.google.com/resources/api-libraries/documentation/vision/v1/java/latest/com/google/api/services/vision/v1/model/EntityAnnotation.html" rel="noreferrer">EntityAnnotation</a>)</p>
<p>Is there anyway to not only get recognized text but also get the <strong>orientation</strong>?<br>
Could Google support it similar to (<a href="https://developers.google.com/resources/api-libraries/documentation/vision/v1/java/latest/com/google/api/services/vision/v1/model/FaceAnnotation.html" rel="noreferrer">FaceAnnotation</a>: getRollAngle)</p>
<p><a href="https://i.stack.imgur.com/fTQrT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fTQrT.png" alt="enter image description here"></a></p>
| 0debug |
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
{
AVFilterContext *ctx = inlink->dst;
TileContext *tile = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
unsigned x0, y0;
get_current_tile_pos(ctx, &x0, &y0);
ff_copy_rectangle2(&tile->draw,
outlink->out_buf->data, outlink->out_buf->linesize,
inlink ->cur_buf->data, inlink ->cur_buf->linesize,
x0, y0 + y, 0, y, inlink->cur_buf->video->w, h);
return 0;
}
| 1threat |
OpenShift CLI: oc vs rhc? : <p>What is the difference between <strong>rhc</strong> and <strong>oc</strong> CLI-tools?</p>
<p>As I see, they do almost the same:</p>
<p><strong>oc</strong>:</p>
<blockquote>
<p>The OpenShift CLI exposes commands for managing your applications, as
well as lower level tools to interact with each component of your
system.</p>
</blockquote>
<p><strong>rhc</strong> does the same, no?</p>
<p>What should I use to manage my containers on OpenShift platform?</p>
| 0debug |
abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6)
{
abi_long ret;
struct stat st;
struct statfs stfs;
void *p;
#ifdef DEBUG
gemu_log("syscall %d", num);
#endif
if(do_strace)
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
switch(num) {
case TARGET_NR_exit:
#ifdef CONFIG_USE_NPTL
if (first_cpu->next_cpu) {
TaskState *ts;
CPUState **lastp;
CPUState *p;
cpu_list_lock();
lastp = &first_cpu;
p = first_cpu;
while (p && p != (CPUState *)cpu_env) {
lastp = &p->next_cpu;
p = p->next_cpu;
}
if (!p)
abort();
*lastp = p->next_cpu;
cpu_list_unlock();
ts = ((CPUState *)cpu_env)->opaque;
if (ts->child_tidptr) {
put_user_u32(0, ts->child_tidptr);
sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
NULL, NULL, 0);
}
pthread_exit(NULL);
}
#endif
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
_exit(arg1);
ret = 0;
break;
case TARGET_NR_read:
if (arg3 == 0)
ret = 0;
else {
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(read(arg1, p, arg3));
unlock_user(p, arg2, ret);
}
break;
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(write(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(open(path(p),
target_to_host_bitmask(arg2, fcntl_flags_tbl),
arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_openat(arg1,
path(p),
target_to_host_bitmask(arg3, fcntl_flags_tbl),
arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
case TARGET_NR_brk:
ret = do_brk(arg1);
break;
case TARGET_NR_fork:
ret = get_errno(do_fork(cpu_env, SIGCHLD, 0, 0, 0, 0));
break;
#ifdef TARGET_NR_waitpid
case TARGET_NR_waitpid:
{
int status;
ret = get_errno(waitpid(arg1, &status, arg3));
if (!is_error(ret) && arg2
&& put_user_s32(host_to_target_waitstatus(status), arg2))
goto efault;
}
break;
#endif
#ifdef TARGET_NR_waitid
case TARGET_NR_waitid:
{
siginfo_t info;
info.si_pid = 0;
ret = get_errno(waitid(arg1, arg2, &info, arg4));
if (!is_error(ret) && arg3 && info.si_pid != 0) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &info);
unlock_user(p, arg3, sizeof(target_siginfo_t));
}
}
break;
#endif
#ifdef TARGET_NR_creat
case TARGET_NR_creat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(creat(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_link:
{
void * p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(link(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_linkat) && defined(__NR_linkat)
case TARGET_NR_linkat:
{
void * p2 = NULL;
if (!arg2 || !arg4)
goto efault;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5));
unlock_user(p, arg2, 0);
unlock_user(p2, arg4, 0);
}
break;
#endif
case TARGET_NR_unlink:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(unlink(p));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat)
case TARGET_NR_unlinkat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_unlinkat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_execve:
{
char **argp, **envp;
int argc, envc;
abi_ulong gp;
abi_ulong guest_argp;
abi_ulong guest_envp;
abi_ulong addr;
char **q;
argc = 0;
guest_argp = arg2;
for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
argc++;
}
envc = 0;
guest_envp = arg3;
for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
if (get_user_ual(addr, gp))
goto efault;
if (!addr)
break;
envc++;
}
argp = alloca((argc + 1) * sizeof(void *));
envp = alloca((envc + 1) * sizeof(void *));
for (gp = guest_argp, q = argp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
for (gp = guest_envp, q = envp; gp;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp))
goto execve_efault;
if (!addr)
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
}
*q = NULL;
if (!(p = lock_user_string(arg1)))
goto execve_efault;
ret = get_errno(execve(p, argp, envp));
unlock_user(p, arg1, 0);
goto execve_end;
execve_efault:
ret = -TARGET_EFAULT;
execve_end:
for (gp = guest_argp, q = argp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
for (gp = guest_envp, q = envp; *q;
gp += sizeof(abi_ulong), q++) {
if (get_user_ual(addr, gp)
|| !addr)
break;
unlock_user(*q, addr, 0);
}
}
break;
case TARGET_NR_chdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chdir(p));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_time
case TARGET_NR_time:
{
time_t host_time;
ret = get_errno(time(&host_time));
if (!is_error(ret)
&& arg1
&& put_user_sal(host_time, arg1))
goto efault;
}
break;
#endif
case TARGET_NR_mknod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mknod(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat)
case TARGET_NR_mknodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mknodat(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_chmod:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chmod(p, arg2));
unlock_user(p, arg1, 0);
break;
#ifdef TARGET_NR_break
case TARGET_NR_break:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldstat
case TARGET_NR_oldstat:
goto unimplemented;
#endif
case TARGET_NR_lseek:
ret = get_errno(lseek(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_getxpid
case TARGET_NR_getxpid:
#else
case TARGET_NR_getpid:
#endif
ret = get_errno(getpid());
break;
case TARGET_NR_mount:
{
void *p2, *p3;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
p3 = lock_user_string(arg3);
if (!p || !p2 || !p3)
ret = -TARGET_EFAULT;
else
ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
unlock_user(p, arg1, 0);
unlock_user(p2, arg2, 0);
unlock_user(p3, arg3, 0);
break;
}
#ifdef TARGET_NR_umount
case TARGET_NR_umount:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount(p));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_stime
case TARGET_NR_stime:
{
time_t host_time;
if (get_user_sal(host_time, arg1))
goto efault;
ret = get_errno(stime(&host_time));
}
break;
#endif
case TARGET_NR_ptrace:
goto unimplemented;
#ifdef TARGET_NR_alarm
case TARGET_NR_alarm:
ret = alarm(arg1);
break;
#endif
#ifdef TARGET_NR_oldfstat
case TARGET_NR_oldfstat:
goto unimplemented;
#endif
#ifdef TARGET_NR_pause
case TARGET_NR_pause:
ret = get_errno(pause());
break;
#endif
#ifdef TARGET_NR_utime
case TARGET_NR_utime:
{
struct utimbuf tbuf, *host_tbuf;
struct target_utimbuf *target_tbuf;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
goto efault;
tbuf.actime = tswapl(target_tbuf->actime);
tbuf.modtime = tswapl(target_tbuf->modtime);
unlock_user_struct(target_tbuf, arg2, 0);
host_tbuf = &tbuf;
} else {
host_tbuf = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utime(p, host_tbuf));
unlock_user(p, arg1, 0);
}
break;
#endif
case TARGET_NR_utimes:
{
struct timeval *tvp, tv[2];
if (arg2) {
if (copy_from_user_timeval(&tv[0], arg2)
|| copy_from_user_timeval(&tv[1],
arg2 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(utimes(p, tvp));
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *tvp, tv[2];
if (arg3) {
if (copy_from_user_timeval(&tv[0], arg3)
|| copy_from_user_timeval(&tv[1],
arg3 + sizeof(struct target_timeval)))
goto efault;
tvp = tv;
} else {
tvp = NULL;
}
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_futimesat(arg1, path(p), tvp));
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_stty
case TARGET_NR_stty:
goto unimplemented;
#endif
#ifdef TARGET_NR_gtty
case TARGET_NR_gtty:
goto unimplemented;
#endif
case TARGET_NR_access:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(access(path(p), arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
case TARGET_NR_faccessat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_faccessat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_nice
case TARGET_NR_nice:
ret = get_errno(nice(arg1));
break;
#endif
#ifdef TARGET_NR_ftime
case TARGET_NR_ftime:
goto unimplemented;
#endif
case TARGET_NR_sync:
sync();
ret = 0;
break;
case TARGET_NR_kill:
ret = get_errno(kill(arg1, target_to_host_signal(arg2)));
break;
case TARGET_NR_rename:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(rename(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_renameat) && defined(__NR_renameat)
case TARGET_NR_renameat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user_string(arg4);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_renameat(arg1, p, arg3, p2));
unlock_user(p2, arg4, 0);
unlock_user(p, arg2, 0);
}
break;
#endif
case TARGET_NR_mkdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(mkdir(p, arg2));
unlock_user(p, arg1, 0);
break;
#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat)
case TARGET_NR_mkdirat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_mkdirat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_rmdir:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(rmdir(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_dup:
ret = get_errno(dup(arg1));
break;
case TARGET_NR_pipe:
ret = do_pipe(cpu_env, arg1, 0);
break;
#ifdef TARGET_NR_pipe2
case TARGET_NR_pipe2:
ret = do_pipe(cpu_env, arg1, arg2);
break;
#endif
case TARGET_NR_times:
{
struct target_tms *tmsp;
struct tms tms;
ret = get_errno(times(&tms));
if (arg1) {
tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
if (!tmsp)
goto efault;
tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime));
tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime));
tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime));
tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime));
}
if (!is_error(ret))
ret = host_to_target_clock_t(ret);
}
break;
#ifdef TARGET_NR_prof
case TARGET_NR_prof:
goto unimplemented;
#endif
#ifdef TARGET_NR_signal
case TARGET_NR_signal:
goto unimplemented;
#endif
case TARGET_NR_acct:
if (arg1 == 0) {
ret = get_errno(acct(NULL));
} else {
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(acct(path(p)));
unlock_user(p, arg1, 0);
}
break;
#ifdef TARGET_NR_umount2
case TARGET_NR_umount2:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(umount2(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_lock
case TARGET_NR_lock:
goto unimplemented;
#endif
case TARGET_NR_ioctl:
ret = do_ioctl(arg1, arg2, arg3);
break;
case TARGET_NR_fcntl:
ret = do_fcntl(arg1, arg2, arg3);
break;
#ifdef TARGET_NR_mpx
case TARGET_NR_mpx:
goto unimplemented;
#endif
case TARGET_NR_setpgid:
ret = get_errno(setpgid(arg1, arg2));
break;
#ifdef TARGET_NR_ulimit
case TARGET_NR_ulimit:
goto unimplemented;
#endif
#ifdef TARGET_NR_oldolduname
case TARGET_NR_oldolduname:
goto unimplemented;
#endif
case TARGET_NR_umask:
ret = get_errno(umask(arg1));
break;
case TARGET_NR_chroot:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chroot(p));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ustat:
goto unimplemented;
case TARGET_NR_dup2:
ret = get_errno(dup2(arg1, arg2));
break;
#ifdef TARGET_NR_getppid
case TARGET_NR_getppid:
ret = get_errno(getppid());
break;
#endif
case TARGET_NR_getpgrp:
ret = get_errno(getpgrp());
break;
case TARGET_NR_setsid:
ret = get_errno(setsid());
break;
#ifdef TARGET_NR_sigaction
case TARGET_NR_sigaction:
{
#if !defined(TARGET_MIPS)
struct target_old_sigaction *old_act;
struct target_sigaction act, oact, *pact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask);
act.sa_flags = old_act->sa_flags;
act.sa_restorer = old_act->sa_restorer;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_mask = oact.sa_mask.sig[0];
old_act->sa_flags = oact.sa_flags;
old_act->sa_restorer = oact.sa_restorer;
unlock_user_struct(old_act, arg3, 1);
}
#else
struct target_sigaction act, oact, *pact, *old_act;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
goto efault;
act._sa_handler = old_act->_sa_handler;
target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
act.sa_flags = old_act->sa_flags;
unlock_user_struct(old_act, arg2, 0);
pact = &act;
} else {
pact = NULL;
}
ret = get_errno(do_sigaction(arg1, pact, &oact));
if (!is_error(ret) && arg3) {
if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
goto efault;
old_act->_sa_handler = oact._sa_handler;
old_act->sa_flags = oact.sa_flags;
old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
old_act->sa_mask.sig[1] = 0;
old_act->sa_mask.sig[2] = 0;
old_act->sa_mask.sig[3] = 0;
unlock_user_struct(old_act, arg3, 1);
}
#endif
}
break;
#endif
case TARGET_NR_rt_sigaction:
{
struct target_sigaction *act;
struct target_sigaction *oact;
if (arg2) {
if (!lock_user_struct(VERIFY_READ, act, arg2, 1))
goto efault;
} else
act = NULL;
if (arg3) {
if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
ret = -TARGET_EFAULT;
goto rt_sigaction_fail;
}
} else
oact = NULL;
ret = get_errno(do_sigaction(arg1, act, oact));
rt_sigaction_fail:
if (act)
unlock_user_struct(act, arg2, 0);
if (oact)
unlock_user_struct(oact, arg3, 1);
}
break;
#ifdef TARGET_NR_sgetmask
case TARGET_NR_sgetmask:
{
sigset_t cur_set;
abi_ulong target_set;
sigprocmask(0, NULL, &cur_set);
host_to_target_old_sigset(&target_set, &cur_set);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_ssetmask
case TARGET_NR_ssetmask:
{
sigset_t set, oset, cur_set;
abi_ulong target_set = arg1;
sigprocmask(0, NULL, &cur_set);
target_to_host_old_sigset(&set, &target_set);
sigorset(&set, &set, &cur_set);
sigprocmask(SIG_SETMASK, &set, &oset);
host_to_target_old_sigset(&target_set, &oset);
ret = target_set;
}
break;
#endif
#ifdef TARGET_NR_sigprocmask
case TARGET_NR_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(arg1, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigprocmask:
{
int how = arg1;
sigset_t set, oldset, *set_ptr;
if (arg2) {
switch(how) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
break;
case TARGET_SIG_UNBLOCK:
how = SIG_UNBLOCK;
break;
case TARGET_SIG_SETMASK:
how = SIG_SETMASK;
break;
default:
ret = -TARGET_EINVAL;
goto fail;
}
if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg2, 0);
set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;
}
ret = get_errno(sigprocmask(how, set_ptr, &oldset));
if (!is_error(ret) && arg3) {
if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &oldset);
unlock_user(p, arg3, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigpending
case TARGET_NR_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_old_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#endif
case TARGET_NR_rt_sigpending:
{
sigset_t set;
ret = get_errno(sigpending(&set));
if (!is_error(ret)) {
if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
goto efault;
host_to_target_sigset(p, &set);
unlock_user(p, arg1, sizeof(target_sigset_t));
}
}
break;
#ifdef TARGET_NR_sigsuspend
case TARGET_NR_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_old_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
#endif
case TARGET_NR_rt_sigsuspend:
{
sigset_t set;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
ret = get_errno(sigsuspend(&set));
}
break;
case TARGET_NR_rt_sigtimedwait:
{
sigset_t set;
struct timespec uts, *puts;
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_sigset(&set, p);
unlock_user(p, arg1, 0);
if (arg3) {
puts = &uts;
target_to_host_timespec(puts, arg3);
} else {
puts = NULL;
}
ret = get_errno(sigtimedwait(&set, &uinfo, puts));
if (!is_error(ret) && arg2) {
if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0)))
goto efault;
host_to_target_siginfo(p, &uinfo);
unlock_user(p, arg2, sizeof(target_siginfo_t));
}
}
break;
case TARGET_NR_rt_sigqueueinfo:
{
siginfo_t uinfo;
if (!(p = lock_user(VERIFY_READ, arg3, sizeof(target_sigset_t), 1)))
goto efault;
target_to_host_siginfo(&uinfo, p);
unlock_user(p, arg1, 0);
ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
}
break;
#ifdef TARGET_NR_sigreturn
case TARGET_NR_sigreturn:
ret = do_sigreturn(cpu_env);
break;
#endif
case TARGET_NR_rt_sigreturn:
ret = do_rt_sigreturn(cpu_env);
break;
case TARGET_NR_sethostname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(sethostname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setrlimit:
{
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
goto efault;
rlim.rlim_cur = tswapl(target_rlim->rlim_cur);
rlim.rlim_max = tswapl(target_rlim->rlim_max);
unlock_user_struct(target_rlim, arg2, 0);
ret = get_errno(setrlimit(resource, &rlim));
}
break;
case TARGET_NR_getrlimit:
{
int resource = arg1;
struct target_rlimit *target_rlim;
struct rlimit rlim;
ret = get_errno(getrlimit(resource, &rlim));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
}
break;
case TARGET_NR_getrusage:
{
struct rusage rusage;
ret = get_errno(getrusage(arg1, &rusage));
if (!is_error(ret)) {
host_to_target_rusage(arg2, &rusage);
}
}
break;
case TARGET_NR_gettimeofday:
{
struct timeval tv;
ret = get_errno(gettimeofday(&tv, NULL));
if (!is_error(ret)) {
if (copy_to_user_timeval(arg1, &tv))
goto efault;
}
}
break;
case TARGET_NR_settimeofday:
{
struct timeval tv;
if (copy_from_user_timeval(&tv, arg1))
goto efault;
ret = get_errno(settimeofday(&tv, NULL));
}
break;
#ifdef TARGET_NR_select
case TARGET_NR_select:
{
struct target_sel_arg_struct *sel;
abi_ulong inp, outp, exp, tvp;
long nsel;
if (!lock_user_struct(VERIFY_READ, sel, arg1, 1))
goto efault;
nsel = tswapl(sel->n);
inp = tswapl(sel->inp);
outp = tswapl(sel->outp);
exp = tswapl(sel->exp);
tvp = tswapl(sel->tvp);
unlock_user_struct(sel, arg1, 0);
ret = do_select(nsel, inp, outp, exp, tvp);
}
break;
#endif
case TARGET_NR_symlink:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg2);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(symlink(p, p2));
unlock_user(p2, arg2, 0);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat)
case TARGET_NR_symlinkat:
{
void *p2;
p = lock_user_string(arg1);
p2 = lock_user_string(arg3);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_symlinkat(p, arg2, p2));
unlock_user(p2, arg3, 0);
unlock_user(p, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_oldlstat
case TARGET_NR_oldlstat:
goto unimplemented;
#endif
case TARGET_NR_readlink:
{
void *p2, *temp;
p = lock_user_string(arg1);
p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else {
if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) {
char real[PATH_MAX];
temp = realpath(exec_path,real);
ret = (temp==NULL) ? get_errno(-1) : strlen(real) ;
snprintf((char *)p2, arg3, "%s", real);
}
else
ret = get_errno(readlink(path(p), p2, arg3));
}
unlock_user(p2, arg2, ret);
unlock_user(p, arg1, 0);
}
break;
#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat)
case TARGET_NR_readlinkat:
{
void *p2;
p = lock_user_string(arg2);
p2 = lock_user(VERIFY_WRITE, arg3, arg4, 0);
if (!p || !p2)
ret = -TARGET_EFAULT;
else
ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4));
unlock_user(p2, arg3, ret);
unlock_user(p, arg2, 0);
}
break;
#endif
#ifdef TARGET_NR_uselib
case TARGET_NR_uselib:
goto unimplemented;
#endif
#ifdef TARGET_NR_swapon
case TARGET_NR_swapon:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapon(p, arg2));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_reboot:
goto unimplemented;
#ifdef TARGET_NR_readdir
case TARGET_NR_readdir:
goto unimplemented;
#endif
#ifdef TARGET_NR_mmap
case TARGET_NR_mmap:
#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE)
{
abi_ulong *v;
abi_ulong v1, v2, v3, v4, v5, v6;
if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
goto efault;
v1 = tswapl(v[0]);
v2 = tswapl(v[1]);
v3 = tswapl(v[2]);
v4 = tswapl(v[3]);
v5 = tswapl(v[4]);
v6 = tswapl(v[5]);
unlock_user(v, arg1, 0);
ret = get_errno(target_mmap(v1, v2, v3,
target_to_host_bitmask(v4, mmap_flags_tbl),
v5, v6));
}
#else
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6));
#endif
break;
#endif
#ifdef TARGET_NR_mmap2
case TARGET_NR_mmap2:
#ifndef MMAP_SHIFT
#define MMAP_SHIFT 12
#endif
ret = get_errno(target_mmap(arg1, arg2, arg3,
target_to_host_bitmask(arg4, mmap_flags_tbl),
arg5,
arg6 << MMAP_SHIFT));
break;
#endif
case TARGET_NR_munmap:
ret = get_errno(target_munmap(arg1, arg2));
break;
case TARGET_NR_mprotect:
ret = get_errno(target_mprotect(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_mremap
case TARGET_NR_mremap:
ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
break;
#endif
#ifdef TARGET_NR_msync
case TARGET_NR_msync:
ret = get_errno(msync(g2h(arg1), arg2, arg3));
break;
#endif
#ifdef TARGET_NR_mlock
case TARGET_NR_mlock:
ret = get_errno(mlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_munlock
case TARGET_NR_munlock:
ret = get_errno(munlock(g2h(arg1), arg2));
break;
#endif
#ifdef TARGET_NR_mlockall
case TARGET_NR_mlockall:
ret = get_errno(mlockall(arg1));
break;
#endif
#ifdef TARGET_NR_munlockall
case TARGET_NR_munlockall:
ret = get_errno(munlockall());
break;
#endif
case TARGET_NR_truncate:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(truncate(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_ftruncate:
ret = get_errno(ftruncate(arg1, arg2));
break;
case TARGET_NR_fchmod:
ret = get_errno(fchmod(arg1, arg2));
break;
#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat)
case TARGET_NR_fchmodat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchmodat(arg1, p, arg3));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getpriority:
ret = sys_getpriority(arg1, arg2);
break;
case TARGET_NR_setpriority:
ret = get_errno(setpriority(arg1, arg2, arg3));
break;
#ifdef TARGET_NR_profil
case TARGET_NR_profil:
goto unimplemented;
#endif
case TARGET_NR_statfs:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs:
if (!is_error(ret)) {
struct target_statfs *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg2, 1);
}
break;
case TARGET_NR_fstatfs:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs;
#ifdef TARGET_NR_statfs64
case TARGET_NR_statfs64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(statfs(path(p), &stfs));
unlock_user(p, arg1, 0);
convert_statfs64:
if (!is_error(ret)) {
struct target_statfs64 *target_stfs;
if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0))
goto efault;
__put_user(stfs.f_type, &target_stfs->f_type);
__put_user(stfs.f_bsize, &target_stfs->f_bsize);
__put_user(stfs.f_blocks, &target_stfs->f_blocks);
__put_user(stfs.f_bfree, &target_stfs->f_bfree);
__put_user(stfs.f_bavail, &target_stfs->f_bavail);
__put_user(stfs.f_files, &target_stfs->f_files);
__put_user(stfs.f_ffree, &target_stfs->f_ffree);
__put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
unlock_user_struct(target_stfs, arg3, 1);
}
break;
case TARGET_NR_fstatfs64:
ret = get_errno(fstatfs(arg1, &stfs));
goto convert_statfs64;
#endif
#ifdef TARGET_NR_ioperm
case TARGET_NR_ioperm:
goto unimplemented;
#endif
#ifdef TARGET_NR_socketcall
case TARGET_NR_socketcall:
ret = do_socketcall(arg1, arg2);
break;
#endif
#ifdef TARGET_NR_accept
case TARGET_NR_accept:
ret = do_accept(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_bind
case TARGET_NR_bind:
ret = do_bind(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_connect
case TARGET_NR_connect:
ret = do_connect(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getpeername
case TARGET_NR_getpeername:
ret = do_getpeername(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockname
case TARGET_NR_getsockname:
ret = do_getsockname(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_getsockopt
case TARGET_NR_getsockopt:
ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_listen
case TARGET_NR_listen:
ret = get_errno(listen(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_recv
case TARGET_NR_recv:
ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_recvfrom
case TARGET_NR_recvfrom:
ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_recvmsg
case TARGET_NR_recvmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 0);
break;
#endif
#ifdef TARGET_NR_send
case TARGET_NR_send:
ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);
break;
#endif
#ifdef TARGET_NR_sendmsg
case TARGET_NR_sendmsg:
ret = do_sendrecvmsg(arg1, arg2, arg3, 1);
break;
#endif
#ifdef TARGET_NR_sendto
case TARGET_NR_sendto:
ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_shutdown
case TARGET_NR_shutdown:
ret = get_errno(shutdown(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_socket
case TARGET_NR_socket:
ret = do_socket(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_socketpair
case TARGET_NR_socketpair:
ret = do_socketpair(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_setsockopt
case TARGET_NR_setsockopt:
ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
break;
#endif
case TARGET_NR_syslog:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
unlock_user(p, arg2, 0);
break;
case TARGET_NR_setitimer:
{
struct itimerval value, ovalue, *pvalue;
if (arg2) {
pvalue = &value;
if (copy_from_user_timeval(&pvalue->it_interval, arg2)
|| copy_from_user_timeval(&pvalue->it_value,
arg2 + sizeof(struct target_timeval)))
goto efault;
} else {
pvalue = NULL;
}
ret = get_errno(setitimer(arg1, pvalue, &ovalue));
if (!is_error(ret) && arg3) {
if (copy_to_user_timeval(arg3,
&ovalue.it_interval)
|| copy_to_user_timeval(arg3 + sizeof(struct target_timeval),
&ovalue.it_value))
goto efault;
}
}
break;
case TARGET_NR_getitimer:
{
struct itimerval value;
ret = get_errno(getitimer(arg1, &value));
if (!is_error(ret) && arg2) {
if (copy_to_user_timeval(arg2,
&value.it_interval)
|| copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
&value.it_value))
goto efault;
}
}
break;
case TARGET_NR_stat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_lstat:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
goto do_stat;
case TARGET_NR_fstat:
{
ret = get_errno(fstat(arg1, &st));
do_stat:
if (!is_error(ret)) {
struct target_stat *target_st;
if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0))
goto efault;
__put_user(st.st_dev, &target_st->st_dev);
__put_user(st.st_ino, &target_st->st_ino);
__put_user(st.st_mode, &target_st->st_mode);
__put_user(st.st_uid, &target_st->st_uid);
__put_user(st.st_gid, &target_st->st_gid);
__put_user(st.st_nlink, &target_st->st_nlink);
__put_user(st.st_rdev, &target_st->st_rdev);
__put_user(st.st_size, &target_st->st_size);
__put_user(st.st_blksize, &target_st->st_blksize);
__put_user(st.st_blocks, &target_st->st_blocks);
__put_user(st.st_atime, &target_st->target_st_atime);
__put_user(st.st_mtime, &target_st->target_st_mtime);
__put_user(st.st_ctime, &target_st->target_st_ctime);
unlock_user_struct(target_st, arg2, 1);
}
}
break;
#ifdef TARGET_NR_olduname
case TARGET_NR_olduname:
goto unimplemented;
#endif
#ifdef TARGET_NR_iopl
case TARGET_NR_iopl:
goto unimplemented;
#endif
case TARGET_NR_vhangup:
ret = get_errno(vhangup());
break;
#ifdef TARGET_NR_idle
case TARGET_NR_idle:
goto unimplemented;
#endif
#ifdef TARGET_NR_syscall
case TARGET_NR_syscall:
ret = do_syscall(cpu_env,arg1 & 0xffff,arg2,arg3,arg4,arg5,arg6,0);
break;
#endif
case TARGET_NR_wait4:
{
int status;
abi_long status_ptr = arg2;
struct rusage rusage, *rusage_ptr;
abi_ulong target_rusage = arg4;
if (target_rusage)
rusage_ptr = &rusage;
else
rusage_ptr = NULL;
ret = get_errno(wait4(arg1, &status, arg3, rusage_ptr));
if (!is_error(ret)) {
if (status_ptr) {
status = host_to_target_waitstatus(status);
if (put_user_s32(status, status_ptr))
goto efault;
}
if (target_rusage)
host_to_target_rusage(target_rusage, &rusage);
}
}
break;
#ifdef TARGET_NR_swapoff
case TARGET_NR_swapoff:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(swapoff(p));
unlock_user(p, arg1, 0);
break;
#endif
case TARGET_NR_sysinfo:
{
struct target_sysinfo *target_value;
struct sysinfo value;
ret = get_errno(sysinfo(&value));
if (!is_error(ret) && arg1)
{
if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0))
goto efault;
__put_user(value.uptime, &target_value->uptime);
__put_user(value.loads[0], &target_value->loads[0]);
__put_user(value.loads[1], &target_value->loads[1]);
__put_user(value.loads[2], &target_value->loads[2]);
__put_user(value.totalram, &target_value->totalram);
__put_user(value.freeram, &target_value->freeram);
__put_user(value.sharedram, &target_value->sharedram);
__put_user(value.bufferram, &target_value->bufferram);
__put_user(value.totalswap, &target_value->totalswap);
__put_user(value.freeswap, &target_value->freeswap);
__put_user(value.procs, &target_value->procs);
__put_user(value.totalhigh, &target_value->totalhigh);
__put_user(value.freehigh, &target_value->freehigh);
__put_user(value.mem_unit, &target_value->mem_unit);
unlock_user_struct(target_value, arg1, 1);
}
}
break;
#ifdef TARGET_NR_ipc
case TARGET_NR_ipc:
ret = do_ipc(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#ifdef TARGET_NR_semget
case TARGET_NR_semget:
ret = get_errno(semget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semop
case TARGET_NR_semop:
ret = get_errno(do_semop(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4);
break;
#endif
#ifdef TARGET_NR_msgctl
case TARGET_NR_msgctl:
ret = do_msgctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_msgget
case TARGET_NR_msgget:
ret = get_errno(msgget(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_msgrcv
case TARGET_NR_msgrcv:
ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_msgsnd
case TARGET_NR_msgsnd:
ret = do_msgsnd(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_shmget
case TARGET_NR_shmget:
ret = get_errno(shmget(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_shmctl
case TARGET_NR_shmctl:
ret = do_shmctl(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmat
case TARGET_NR_shmat:
ret = do_shmat(arg1, arg2, arg3);
break;
#endif
#ifdef TARGET_NR_shmdt
case TARGET_NR_shmdt:
ret = do_shmdt(arg1);
break;
#endif
case TARGET_NR_fsync:
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_clone:
#if defined(TARGET_SH4)
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
#elif defined(TARGET_CRIS)
ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5));
#else
ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5));
#endif
break;
#ifdef __NR_exit_group
case TARGET_NR_exit_group:
#ifdef TARGET_GPROF
_mcleanup();
#endif
gdb_exit(cpu_env, arg1);
ret = get_errno(exit_group(arg1));
break;
#endif
case TARGET_NR_setdomainname:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(setdomainname(p, arg2));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_uname:
{
struct new_utsname * buf;
if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0))
goto efault;
ret = get_errno(sys_uname(buf));
if (!is_error(ret)) {
strcpy (buf->machine, UNAME_MACHINE);
if (qemu_uname_release && *qemu_uname_release)
strcpy (buf->release, qemu_uname_release);
}
unlock_user_struct(buf, arg1, 1);
}
break;
#ifdef TARGET_I386
case TARGET_NR_modify_ldt:
ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
break;
#if !defined(TARGET_X86_64)
case TARGET_NR_vm86old:
goto unimplemented;
case TARGET_NR_vm86:
ret = do_vm86(cpu_env, arg1, arg2);
break;
#endif
#endif
case TARGET_NR_adjtimex:
goto unimplemented;
#ifdef TARGET_NR_create_module
case TARGET_NR_create_module:
#endif
case TARGET_NR_init_module:
case TARGET_NR_delete_module:
#ifdef TARGET_NR_get_kernel_syms
case TARGET_NR_get_kernel_syms:
#endif
goto unimplemented;
case TARGET_NR_quotactl:
goto unimplemented;
case TARGET_NR_getpgid:
ret = get_errno(getpgid(arg1));
break;
case TARGET_NR_fchdir:
ret = get_errno(fchdir(arg1));
break;
#ifdef TARGET_NR_bdflush
case TARGET_NR_bdflush:
goto unimplemented;
#endif
#ifdef TARGET_NR_sysfs
case TARGET_NR_sysfs:
goto unimplemented;
#endif
case TARGET_NR_personality:
ret = get_errno(personality(arg1));
break;
#ifdef TARGET_NR_afs_syscall
case TARGET_NR_afs_syscall:
goto unimplemented;
#endif
#ifdef TARGET_NR__llseek
case TARGET_NR__llseek:
{
#if defined (__x86_64__)
ret = get_errno(lseek(arg1, ((uint64_t )arg2 << 32) | arg3, arg5));
if (put_user_s64(ret, arg4))
goto efault;
#else
int64_t res;
ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
if (put_user_s64(res, arg4))
goto efault;
#endif
}
break;
#endif
case TARGET_NR_getdents:
#if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
{
struct target_dirent *target_dirp;
struct linux_dirent *dirp;
abi_long count = arg3;
dirp = malloc(count);
if (!dirp) {
ret = -TARGET_ENOMEM;
goto fail;
}
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
struct target_dirent *tde;
int len = ret;
int reclen, treclen;
int count1, tnamelen;
count1 = 0;
de = dirp;
if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
tde = target_dirp;
while (len > 0) {
reclen = de->d_reclen;
treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long)));
tde->d_reclen = tswap16(treclen);
tde->d_ino = tswapl(de->d_ino);
tde->d_off = tswapl(de->d_off);
tnamelen = treclen - (2 * sizeof(abi_long) + 2);
if (tnamelen > 256)
tnamelen = 256;
pstrcpy(tde->d_name, tnamelen, de->d_name);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
tde = (struct target_dirent *)((char *)tde + treclen);
count1 += treclen;
}
ret = count1;
unlock_user(target_dirp, arg2, ret);
}
free(dirp);
}
#else
{
struct linux_dirent *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswapls(&de->d_ino);
tswapls(&de->d_off);
de = (struct linux_dirent *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
#endif
break;
#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
case TARGET_NR_getdents64:
{
struct linux_dirent64 *dirp;
abi_long count = arg3;
if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
goto efault;
ret = get_errno(sys_getdents64(arg1, dirp, count));
if (!is_error(ret)) {
struct linux_dirent64 *de;
int len = ret;
int reclen;
de = dirp;
while (len > 0) {
reclen = de->d_reclen;
if (reclen > len)
break;
de->d_reclen = tswap16(reclen);
tswap64s((uint64_t *)&de->d_ino);
tswap64s((uint64_t *)&de->d_off);
de = (struct linux_dirent64 *)((char *)de + reclen);
len -= reclen;
}
}
unlock_user(dirp, arg2, ret);
}
break;
#endif
#ifdef TARGET_NR__newselect
case TARGET_NR__newselect:
ret = do_select(arg1, arg2, arg3, arg4, arg5);
break;
#endif
#ifdef TARGET_NR_poll
case TARGET_NR_poll:
{
struct target_pollfd *target_pfd;
unsigned int nfds = arg2;
int timeout = arg3;
struct pollfd *pfd;
unsigned int i;
target_pfd = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_pollfd) * nfds, 1);
if (!target_pfd)
goto efault;
pfd = alloca(sizeof(struct pollfd) * nfds);
for(i = 0; i < nfds; i++) {
pfd[i].fd = tswap32(target_pfd[i].fd);
pfd[i].events = tswap16(target_pfd[i].events);
}
ret = get_errno(poll(pfd, nfds, timeout));
if (!is_error(ret)) {
for(i = 0; i < nfds; i++) {
target_pfd[i].revents = tswap16(pfd[i].revents);
}
ret += nfds * (sizeof(struct target_pollfd)
- sizeof(struct pollfd));
}
unlock_user(target_pfd, arg1, ret);
}
break;
#endif
case TARGET_NR_flock:
ret = get_errno(flock(arg1, arg2));
break;
case TARGET_NR_readv:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_WRITE, vec, arg2, count, 0) < 0)
goto efault;
ret = get_errno(readv(arg1, vec, count));
unlock_iovec(vec, arg2, count, 1);
}
break;
case TARGET_NR_writev:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(writev(arg1, vec, count));
unlock_iovec(vec, arg2, count, 0);
}
break;
case TARGET_NR_getsid:
ret = get_errno(getsid(arg1));
break;
#if defined(TARGET_NR_fdatasync)
case TARGET_NR_fdatasync:
ret = get_errno(fdatasync(arg1));
break;
#endif
case TARGET_NR__sysctl:
ret = -TARGET_ENOTDIR;
break;
case TARGET_NR_sched_setparam:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg2, 0);
ret = get_errno(sched_setparam(arg1, &schp));
}
break;
case TARGET_NR_sched_getparam:
{
struct sched_param *target_schp;
struct sched_param schp;
ret = get_errno(sched_getparam(arg1, &schp));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
goto efault;
target_schp->sched_priority = tswap32(schp.sched_priority);
unlock_user_struct(target_schp, arg2, 1);
}
}
break;
case TARGET_NR_sched_setscheduler:
{
struct sched_param *target_schp;
struct sched_param schp;
if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
unlock_user_struct(target_schp, arg3, 0);
ret = get_errno(sched_setscheduler(arg1, arg2, &schp));
}
break;
case TARGET_NR_sched_getscheduler:
ret = get_errno(sched_getscheduler(arg1));
break;
case TARGET_NR_sched_yield:
ret = get_errno(sched_yield());
break;
case TARGET_NR_sched_get_priority_max:
ret = get_errno(sched_get_priority_max(arg1));
break;
case TARGET_NR_sched_get_priority_min:
ret = get_errno(sched_get_priority_min(arg1));
break;
case TARGET_NR_sched_rr_get_interval:
{
struct timespec ts;
ret = get_errno(sched_rr_get_interval(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
}
break;
case TARGET_NR_nanosleep:
{
struct timespec req, rem;
target_to_host_timespec(&req, arg1);
ret = get_errno(nanosleep(&req, &rem));
if (is_error(ret) && arg2) {
host_to_target_timespec(arg2, &rem);
}
}
break;
#ifdef TARGET_NR_query_module
case TARGET_NR_query_module:
goto unimplemented;
#endif
#ifdef TARGET_NR_nfsservctl
case TARGET_NR_nfsservctl:
goto unimplemented;
#endif
case TARGET_NR_prctl:
switch (arg1)
{
case PR_GET_PDEATHSIG:
{
int deathsig;
ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
if (!is_error(ret) && arg2
&& put_user_ual(deathsig, arg2))
goto efault;
}
break;
default:
ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
break;
}
break;
#ifdef TARGET_NR_arch_prctl
case TARGET_NR_arch_prctl:
#if defined(TARGET_I386) && !defined(TARGET_ABI32)
ret = do_arch_prctl(cpu_env, arg1, arg2);
break;
#else
goto unimplemented;
#endif
#endif
#ifdef TARGET_NR_pread
case TARGET_NR_pread:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread(arg1, p, arg3, arg4));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
arg4 = arg5;
#endif
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite(arg1, p, arg3, arg4));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_pread64
case TARGET_NR_pread64:
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite64:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
unlock_user(p, arg2, 0);
break;
#endif
case TARGET_NR_getcwd:
if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
goto efault;
ret = get_errno(sys_getcwd1(p, arg2));
unlock_user(p, arg1, ret);
break;
case TARGET_NR_capget:
goto unimplemented;
case TARGET_NR_capset:
goto unimplemented;
case TARGET_NR_sigaltstack:
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
defined(TARGET_M68K)
ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
break;
#else
goto unimplemented;
#endif
case TARGET_NR_sendfile:
goto unimplemented;
#ifdef TARGET_NR_getpmsg
case TARGET_NR_getpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_putpmsg
case TARGET_NR_putpmsg:
goto unimplemented;
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
ret = get_errno(do_fork(cpu_env, CLONE_VFORK | CLONE_VM | SIGCHLD,
0, 0, 0, 0));
break;
#endif
#ifdef TARGET_NR_ugetrlimit
case TARGET_NR_ugetrlimit:
{
struct rlimit rlim;
ret = get_errno(getrlimit(arg1, &rlim));
if (!is_error(ret)) {
struct target_rlimit *target_rlim;
if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
goto efault;
target_rlim->rlim_cur = tswapl(rlim.rlim_cur);
target_rlim->rlim_max = tswapl(rlim.rlim_max);
unlock_user_struct(target_rlim, arg2, 1);
}
break;
}
#endif
#ifdef TARGET_NR_truncate64
case TARGET_NR_truncate64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_ftruncate64
case TARGET_NR_ftruncate64:
ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_stat64
case TARGET_NR_stat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(stat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_lstat64
case TARGET_NR_lstat64:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lstat(path(p), &st));
unlock_user(p, arg1, 0);
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#ifdef TARGET_NR_fstat64
case TARGET_NR_fstat64:
ret = get_errno(fstat(arg1, &st));
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg2, &st);
break;
#endif
#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \
(defined(__NR_fstatat64) || defined(__NR_newfstatat))
#ifdef TARGET_NR_fstatat64
case TARGET_NR_fstatat64:
#endif
#ifdef TARGET_NR_newfstatat
case TARGET_NR_newfstatat:
#endif
if (!(p = lock_user_string(arg2)))
goto efault;
#ifdef __NR_fstatat64
ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4));
#else
ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4));
#endif
if (!is_error(ret))
ret = host_to_target_stat64(cpu_env, arg3, &st);
break;
#endif
#ifdef USE_UID16
case TARGET_NR_lchown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_getuid:
ret = get_errno(high2lowuid(getuid()));
break;
case TARGET_NR_getgid:
ret = get_errno(high2lowgid(getgid()));
break;
case TARGET_NR_geteuid:
ret = get_errno(high2lowuid(geteuid()));
break;
case TARGET_NR_getegid:
ret = get_errno(high2lowgid(getegid()));
break;
case TARGET_NR_setreuid:
ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
break;
case TARGET_NR_setregid:
ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
break;
case TARGET_NR_getgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 2, 0);
if (!target_grouplist)
goto efault;
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap16(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 2);
}
}
break;
case TARGET_NR_setgroups:
{
int gidsetsize = arg1;
uint16_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap16(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
case TARGET_NR_fchown:
ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
break;
#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat)
case TARGET_NR_fchownat:
if (!(p = lock_user_string(arg2)))
goto efault;
ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5));
unlock_user(p, arg2, 0);
break;
#endif
#ifdef TARGET_NR_setresuid
case TARGET_NR_setresuid:
ret = get_errno(setresuid(low2highuid(arg1),
low2highuid(arg2),
low2highuid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresuid
case TARGET_NR_getresuid:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u16(high2lowuid(ruid), arg1)
|| put_user_u16(high2lowuid(euid), arg2)
|| put_user_u16(high2lowuid(suid), arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_setresgid:
ret = get_errno(setresgid(low2highgid(arg1),
low2highgid(arg2),
low2highgid(arg3)));
break;
#endif
#ifdef TARGET_NR_getresgid
case TARGET_NR_getresgid:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u16(high2lowgid(rgid), arg1)
|| put_user_u16(high2lowgid(egid), arg2)
|| put_user_u16(high2lowgid(sgid), arg3))
goto efault;
}
}
break;
#endif
case TARGET_NR_chown:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3)));
unlock_user(p, arg1, 0);
break;
case TARGET_NR_setuid:
ret = get_errno(setuid(low2highuid(arg1)));
break;
case TARGET_NR_setgid:
ret = get_errno(setgid(low2highgid(arg1)));
break;
case TARGET_NR_setfsuid:
ret = get_errno(setfsuid(arg1));
break;
case TARGET_NR_setfsgid:
ret = get_errno(setfsgid(arg1));
break;
#endif
#ifdef TARGET_NR_lchown32
case TARGET_NR_lchown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(lchown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_getuid32
case TARGET_NR_getuid32:
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)
case TARGET_NR_getxuid:
{
uid_t euid;
euid=geteuid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;
}
ret = get_errno(getuid());
break;
#endif
#if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)
case TARGET_NR_getxgid:
{
uid_t egid;
egid=getegid();
((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;
}
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_getgid32
case TARGET_NR_getgid32:
ret = get_errno(getgid());
break;
#endif
#ifdef TARGET_NR_geteuid32
case TARGET_NR_geteuid32:
ret = get_errno(geteuid());
break;
#endif
#ifdef TARGET_NR_getegid32
case TARGET_NR_getegid32:
ret = get_errno(getegid());
break;
#endif
#ifdef TARGET_NR_setreuid32
case TARGET_NR_setreuid32:
ret = get_errno(setreuid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_setregid32
case TARGET_NR_setregid32:
ret = get_errno(setregid(arg1, arg2));
break;
#endif
#ifdef TARGET_NR_getgroups32
case TARGET_NR_getgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
ret = get_errno(getgroups(gidsetsize, grouplist));
if (gidsetsize == 0)
break;
if (!is_error(ret)) {
target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < ret; i++)
target_grouplist[i] = tswap32(grouplist[i]);
unlock_user(target_grouplist, arg2, gidsetsize * 4);
}
}
break;
#endif
#ifdef TARGET_NR_setgroups32
case TARGET_NR_setgroups32:
{
int gidsetsize = arg1;
uint32_t *target_grouplist;
gid_t *grouplist;
int i;
grouplist = alloca(gidsetsize * sizeof(gid_t));
target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
if (!target_grouplist) {
ret = -TARGET_EFAULT;
goto fail;
}
for(i = 0;i < gidsetsize; i++)
grouplist[i] = tswap32(target_grouplist[i]);
unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
#endif
#ifdef TARGET_NR_fchown32
case TARGET_NR_fchown32:
ret = get_errno(fchown(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_setresuid32
case TARGET_NR_setresuid32:
ret = get_errno(setresuid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresuid32
case TARGET_NR_getresuid32:
{
uid_t ruid, euid, suid;
ret = get_errno(getresuid(&ruid, &euid, &suid));
if (!is_error(ret)) {
if (put_user_u32(ruid, arg1)
|| put_user_u32(euid, arg2)
|| put_user_u32(suid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_setresgid32
case TARGET_NR_setresgid32:
ret = get_errno(setresgid(arg1, arg2, arg3));
break;
#endif
#ifdef TARGET_NR_getresgid32
case TARGET_NR_getresgid32:
{
gid_t rgid, egid, sgid;
ret = get_errno(getresgid(&rgid, &egid, &sgid));
if (!is_error(ret)) {
if (put_user_u32(rgid, arg1)
|| put_user_u32(egid, arg2)
|| put_user_u32(sgid, arg3))
goto efault;
}
}
break;
#endif
#ifdef TARGET_NR_chown32
case TARGET_NR_chown32:
if (!(p = lock_user_string(arg1)))
goto efault;
ret = get_errno(chown(p, arg2, arg3));
unlock_user(p, arg1, 0);
break;
#endif
#ifdef TARGET_NR_setuid32
case TARGET_NR_setuid32:
ret = get_errno(setuid(arg1));
break;
#endif
#ifdef TARGET_NR_setgid32
case TARGET_NR_setgid32:
ret = get_errno(setgid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsuid32
case TARGET_NR_setfsuid32:
ret = get_errno(setfsuid(arg1));
break;
#endif
#ifdef TARGET_NR_setfsgid32
case TARGET_NR_setfsgid32:
ret = get_errno(setfsgid(arg1));
break;
#endif
case TARGET_NR_pivot_root:
goto unimplemented;
#ifdef TARGET_NR_mincore
case TARGET_NR_mincore:
{
void *a;
ret = -TARGET_EFAULT;
if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
goto efault;
if (!(p = lock_user_string(arg3)))
goto mincore_fail;
ret = get_errno(mincore(a, arg2, p));
unlock_user(p, arg3, ret);
mincore_fail:
unlock_user(a, arg1, 0);
}
break;
#endif
#ifdef TARGET_NR_arm_fadvise64_64
case TARGET_NR_arm_fadvise64_64:
{
abi_long temp;
temp = arg3;
arg3 = arg4;
arg4 = temp;
}
#endif
#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)
#ifdef TARGET_NR_fadvise64_64
case TARGET_NR_fadvise64_64:
#endif
#ifdef TARGET_NR_fadvise64
case TARGET_NR_fadvise64:
#endif
#ifdef TARGET_S390X
switch (arg4) {
case 4: arg4 = POSIX_FADV_NOREUSE + 1; break;
case 5: arg4 = POSIX_FADV_NOREUSE + 2; break;
case 6: arg4 = POSIX_FADV_DONTNEED; break;
case 7: arg4 = POSIX_FADV_NOREUSE; break;
default: break;
}
#endif
ret = -posix_fadvise(arg1, arg2, arg3, arg4);
break;
#endif
#ifdef TARGET_NR_madvise
case TARGET_NR_madvise:
ret = get_errno(0);
break;
#endif
#if TARGET_ABI_BITS == 32
case TARGET_NR_fcntl64:
{
int cmd;
struct flock64 fl;
struct target_flock64 *target_fl;
#ifdef TARGET_ARM
struct target_eabi_flock64 *target_efl;
#endif
cmd = target_to_host_fcntl_cmd(arg2);
if (cmd == -TARGET_EINVAL)
return cmd;
switch(arg2) {
case TARGET_F_GETLK64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
if (ret == 0) {
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_WRITE, target_efl, arg3, 0))
goto efault;
target_efl->l_type = tswap16(fl.l_type);
target_efl->l_whence = tswap16(fl.l_whence);
target_efl->l_start = tswap64(fl.l_start);
target_efl->l_len = tswap64(fl.l_len);
target_efl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_efl, arg3, 1);
} else
#endif
{
if (!lock_user_struct(VERIFY_WRITE, target_fl, arg3, 0))
goto efault;
target_fl->l_type = tswap16(fl.l_type);
target_fl->l_whence = tswap16(fl.l_whence);
target_fl->l_start = tswap64(fl.l_start);
target_fl->l_len = tswap64(fl.l_len);
target_fl->l_pid = tswap32(fl.l_pid);
unlock_user_struct(target_fl, arg3, 1);
}
}
break;
case TARGET_F_SETLK64:
case TARGET_F_SETLKW64:
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi) {
if (!lock_user_struct(VERIFY_READ, target_efl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_efl->l_type);
fl.l_whence = tswap16(target_efl->l_whence);
fl.l_start = tswap64(target_efl->l_start);
fl.l_len = tswap64(target_efl->l_len);
fl.l_pid = tswap32(target_efl->l_pid);
unlock_user_struct(target_efl, arg3, 0);
} else
#endif
{
if (!lock_user_struct(VERIFY_READ, target_fl, arg3, 1))
goto efault;
fl.l_type = tswap16(target_fl->l_type);
fl.l_whence = tswap16(target_fl->l_whence);
fl.l_start = tswap64(target_fl->l_start);
fl.l_len = tswap64(target_fl->l_len);
fl.l_pid = tswap32(target_fl->l_pid);
unlock_user_struct(target_fl, arg3, 0);
}
ret = get_errno(fcntl(arg1, cmd, &fl));
break;
default:
ret = do_fcntl(arg1, arg2, arg3);
break;
}
break;
}
#endif
#ifdef TARGET_NR_cacheflush
case TARGET_NR_cacheflush:
ret = 0;
break;
#endif
#ifdef TARGET_NR_security
case TARGET_NR_security:
goto unimplemented;
#endif
#ifdef TARGET_NR_getpagesize
case TARGET_NR_getpagesize:
ret = TARGET_PAGE_SIZE;
break;
#endif
case TARGET_NR_gettid:
ret = get_errno(gettid());
break;
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
#ifdef TARGET_ARM
if (((CPUARMState *)cpu_env)->eabi)
{
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
}
#endif
ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
#else
ret = get_errno(readahead(arg1, arg2, arg3));
#endif
break;
#endif
#ifdef TARGET_NR_setxattr
case TARGET_NR_setxattr:
case TARGET_NR_lsetxattr:
case TARGET_NR_fsetxattr:
case TARGET_NR_getxattr:
case TARGET_NR_lgetxattr:
case TARGET_NR_fgetxattr:
case TARGET_NR_listxattr:
case TARGET_NR_llistxattr:
case TARGET_NR_flistxattr:
case TARGET_NR_removexattr:
case TARGET_NR_lremovexattr:
case TARGET_NR_fremovexattr:
ret = -TARGET_EOPNOTSUPP;
break;
#endif
#ifdef TARGET_NR_set_thread_area
case TARGET_NR_set_thread_area:
#if defined(TARGET_MIPS)
((CPUMIPSState *) cpu_env)->tls_value = arg1;
ret = 0;
break;
#elif defined(TARGET_CRIS)
if (arg1 & 0xff)
ret = -TARGET_EINVAL;
else {
((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
ret = 0;
}
break;
#elif defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_set_thread_area(cpu_env, arg1);
break;
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_get_thread_area
case TARGET_NR_get_thread_area:
#if defined(TARGET_I386) && defined(TARGET_ABI32)
ret = do_get_thread_area(cpu_env, arg1);
#else
goto unimplemented_nowarn;
#endif
#endif
#ifdef TARGET_NR_getdomainname
case TARGET_NR_getdomainname:
goto unimplemented_nowarn;
#endif
#ifdef TARGET_NR_clock_gettime
case TARGET_NR_clock_gettime:
{
struct timespec ts;
ret = get_errno(clock_gettime(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_getres
case TARGET_NR_clock_getres:
{
struct timespec ts;
ret = get_errno(clock_getres(arg1, &ts));
if (!is_error(ret)) {
host_to_target_timespec(arg2, &ts);
}
break;
}
#endif
#ifdef TARGET_NR_clock_nanosleep
case TARGET_NR_clock_nanosleep:
{
struct timespec ts;
target_to_host_timespec(&ts, arg3);
ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL));
if (arg4)
host_to_target_timespec(arg4, &ts);
break;
}
#endif
#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
case TARGET_NR_set_tid_address:
ret = get_errno(set_tid_address((int *)g2h(arg1)));
break;
#endif
#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
case TARGET_NR_tkill:
ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));
break;
#endif
#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
case TARGET_NR_tgkill:
ret = get_errno(sys_tgkill((int)arg1, (int)arg2,
target_to_host_signal(arg3)));
break;
#endif
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
goto unimplemented_nowarn;
#endif
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
case TARGET_NR_utimensat:
{
struct timespec *tsp, ts[2];
if (!arg3) {
tsp = NULL;
} else {
target_to_host_timespec(ts, arg3);
target_to_host_timespec(ts+1, arg3+sizeof(struct target_timespec));
tsp = ts;
}
if (!arg2)
ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
else {
if (!(p = lock_user_string(arg2))) {
ret = -TARGET_EFAULT;
goto fail;
}
ret = get_errno(sys_utimensat(arg1, path(p), tsp, arg4));
unlock_user(p, arg2, 0);
}
}
break;
#endif
#if defined(CONFIG_USE_NPTL)
case TARGET_NR_futex:
ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
break;
#endif
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
break;
#endif
#if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
case TARGET_NR_inotify_add_watch:
p = lock_user_string(arg2);
ret = get_errno(sys_inotify_add_watch(arg1, path(p), arg3));
unlock_user(p, arg2, 0);
break;
#endif
#if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
case TARGET_NR_inotify_rm_watch:
ret = get_errno(sys_inotify_rm_watch(arg1, arg2));
break;
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
case TARGET_NR_mq_open:
{
struct mq_attr posix_mq_attr;
p = lock_user_string(arg1 - 1);
if (arg4 != 0)
copy_from_user_mq_attr (&posix_mq_attr, arg4);
ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
unlock_user (p, arg1, 0);
}
break;
case TARGET_NR_mq_unlink:
p = lock_user_string(arg1 - 1);
ret = get_errno(mq_unlink(p));
unlock_user (p, arg1, 0);
break;
case TARGET_NR_mq_timedsend:
{
struct timespec ts;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_send(arg1, p, arg3, arg4));
unlock_user (p, arg2, arg3);
}
break;
case TARGET_NR_mq_timedreceive:
{
struct timespec ts;
unsigned int prio;
p = lock_user (VERIFY_READ, arg2, arg3, 1);
if (arg5 != 0) {
target_to_host_timespec(&ts, arg5);
ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts));
host_to_target_timespec(arg5, &ts);
}
else
ret = get_errno(mq_receive(arg1, p, arg3, &prio));
unlock_user (p, arg2, arg3);
if (arg4 != 0)
put_user_u32(prio, arg4);
}
break;
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
if (arg3 != 0) {
ret = mq_getattr(arg1, &posix_mq_attr_out);
copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
}
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
}
}
break;
#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee
case TARGET_NR_tee:
{
ret = get_errno(tee(arg1,arg2,arg3,arg4));
}
break;
#endif
#ifdef TARGET_NR_splice
case TARGET_NR_splice:
{
loff_t loff_in, loff_out;
loff_t *ploff_in = NULL, *ploff_out = NULL;
if(arg2) {
get_user_u64(loff_in, arg2);
ploff_in = &loff_in;
}
if(arg4) {
get_user_u64(loff_out, arg2);
ploff_out = &loff_out;
}
ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
}
break;
#endif
#ifdef TARGET_NR_vmsplice
case TARGET_NR_vmsplice:
{
int count = arg3;
struct iovec *vec;
vec = alloca(count * sizeof(struct iovec));
if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0)
goto efault;
ret = get_errno(vmsplice(arg1, vec, count, arg4));
unlock_iovec(vec, arg2, count, 0);
}
break;
#endif
#endif
#ifdef CONFIG_EVENTFD
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
break;
#endif
#if defined(TARGET_NR_eventfd2)
case TARGET_NR_eventfd2:
ret = get_errno(eventfd(arg1, arg2));
break;
#endif
#endif
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
unimplemented_nowarn:
#endif
ret = -TARGET_ENOSYS;
break;
}
fail:
#ifdef DEBUG
gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
#endif
if(do_strace)
print_syscall_ret(num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
goto fail;
} | 1threat |
How to read csv without header and name them with names while reading in pyspark? : <pre><code>100000,20160214,93374987
100000,20160214,1925301
100000,20160216,1896542
100000,20160216,84167419
100000,20160216,77273616
100000,20160507,1303015
</code></pre>
<p>I want to read the csv file which has no column names in first row.
How to read it and name the columns with my specified names in the same time ?
for now, I just renamed the original columns with my specified names like this:</p>
<pre><code>df = spark.read.csv("user_click_seq.csv",header=False)
df = df.withColumnRenamed("_c0", "member_srl")
df = df.withColumnRenamed("_c1", "click_day")
df = df.withColumnRenamed("_c2", "productid")
</code></pre>
<p>Any better way ?</p>
| 0debug |
Do i need to know jquery to learn and work on react js / angular js : <p>I just completed HTML, CSS & JavaScript and i think im pretty good and confident in them i want learn angular js / react js to become a Complete Front End Developer</p>
<p>SO</p>
<p>Do i need to learn JQuery before learning angular js / react js & PLS SUGGEST me one of the framework too.</p>
<p>Thanks.</p>
| 0debug |
START_TEST(qstring_from_substr_test)
{
QString *qs;
qs = qstring_from_substr("virtualization", 3, 9);
fail_unless(qs != NULL);
fail_unless(strcmp(qstring_get_str(qs), "tualiza") == 0);
QDECREF(qs);
}
| 1threat |
I cannot find my mistake. It should bounce off the paddles and it should restart once it is gameover. Can someone find my mistakes? : So this is my entire code and what it does not do, but should definitely do is first bounce off when colliding with the paddles and second if it does not do so then once the game enters in gameover mode once a key is pressed it should restart the game. Now I've tried several things and nothing seems to work.
Can someone please find a solution and try to explain what I did wrong?
// variables for the ball
int ball_width = 15, ball_height = 15;
int ballX = width/2, ballY = height/2;
//
// variables for the paddles
int paddle_width = 20, paddle_height = 150;
int paddle1 = 60, paddle2;
//
// direction variables
int directionX = 15, directionY = 15;
//
// variables for the score
int scorecounter = 0;
//
//game states
boolean playing = false, gameover = false, finalscore = false, score = true;
void setup () {
size (1900, 1300); // the field game is going to be 1900x1300 px big
rectMode (CENTER);
paddle2 = width - 60;
}
void draw () {
background (0); // black background
playing ();
gameover ();
finalscore();
}
//
void playing () {
if (keyPressed) {
playing = true;
}
if (!playing) { // playing = false
fill(255);
textSize(80);
textAlign(CENTER);
text("Press Space to Play", width/2, height/4);
fill (255);
ellipse (width/2, height/2, ball_width, ball_height); // this is the starting point of the ball
fill (255, 10, 20);
rect(paddle1, (height/2), paddle_width, paddle_height); // red pong
fill (60, 255, 0);
rect(paddle2, (height/2), paddle_width, paddle_height); // green pong
}
if (playing) { // playing = true
score();
ballX = ballX + directionX;
ballY = ballY + directionY;
fill (255);
ellipse (ballX, ballY, ball_width, ball_height);
fill ( 255, 10, 20 );
rect(paddle1, mouseY, paddle_width, paddle_height); // red pong
fill ( 60, 255, 0 );
rect(paddle2, mouseY, paddle_width, paddle_height); // green pong
if ( ballY > height ) {
directionY = -directionY;
} // if the ball reaches the lower wall it will bounce off
if ( ballY < 0 ) {
directionY = -directionY;
} // if the ball reaches the upper wall it will bounce off
if ( ballX > width || ballX < 0 ) {
gameover = true; }
}
if (ballX == paddle1 && ballY <= paddle_height) {
directionX = -directionX;
directionY = -directionY;
}
if (ballX == paddle2 && ballY <= paddle_height) {
directionX = -directionX;
directionY = -directionY;
}
}
void gameover () {
if (gameover) {
background (0);
}
finalscore ();
score = false;
if (keyPressed) {
playing = true;
}
}
void score () {
if (playing) {
fill(255);
textSize(45);
textAlign(CENTER);
text ( scorecounter, width/2, height/4);
if (ballX == paddle1 && ballY <= paddle_height) {
scorecounter = scorecounter + 10;
}
if (ballX == paddle2 && ballX <= paddle_height) {
scorecounter = scorecounter + 10;
}
}
if (!playing) {
score = false;
}
}
void finalscore () {
if (gameover) {
score = false;
fill(255);
textSize(45);
textAlign(CENTER);
text("Game Over. Press a key to play again.", width/2, height/4);
fill(255);
textSize(80);
textAlign(CENTER);
text("You scored " + scorecounter + " points", width/2, (height/4) * 3);
if (keyPressed) {
playing = playing;
}
}
}
| 0debug |
is there any soloution for OnTick patched? : I Had a problem on the script that when i enter the game it told " Error message: patchOnTick was not successful "
So This is The If There any solutions i hope you comment below
The Script for This Game ```https://krunker.io/```
This is the script `https://pastebin.com/raw/ucUT0mdC`
| 0debug |
void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, ptrdiff_t pitch,
const uint8_t *flags)
{
int i, shift, sp1, sp2, sp3, sp4;
const int32_t *src;
int32_t *dst;
int tmp[64];
int t0, t1, t2, t3, t4, t5, t6, t7, t8;
#define COMPENSATE(x) (x)
src = in;
dst = tmp;
for (i = 0; i < 8; i++) {
if (flags[i]) {
shift = !(i & 4);
sp1 = src[ 0] << shift;
sp2 = src[ 8] << shift;
sp3 = src[16] << shift;
sp4 = src[24] << shift;
INV_HAAR8( sp1, sp2, sp3, sp4,
src[32], src[40], src[48], src[56],
dst[ 0], dst[ 8], dst[16], dst[24],
dst[32], dst[40], dst[48], dst[56],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
} else
dst[ 0] = dst[ 8] = dst[16] = dst[24] =
dst[32] = dst[40] = dst[48] = dst[56] = 0;
src++;
dst++;
}
#undef COMPENSATE
#define COMPENSATE(x) (x)
src = tmp;
for (i = 0; i < 8; i++) {
if ( !src[0] && !src[1] && !src[2] && !src[3]
&& !src[4] && !src[5] && !src[6] && !src[7]) {
memset(out, 0, 8 * sizeof(out[0]));
} else {
INV_HAAR8(src[0], src[1], src[2], src[3],
src[4], src[5], src[6], src[7],
out[0], out[1], out[2], out[3],
out[4], out[5], out[6], out[7],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
}
src += 8;
out += pitch;
}
#undef COMPENSATE
}
| 1threat |
how to grep string and assgin to variable in perl : I have a file with the below details;
cont:i-02dd208bf1d81c254
rs:i-0098ad0b59b7fe7cf
I want to use value for "i-XXX" in associated "cont" name and then assign to another variable.
How to achieve this? | 0debug |
Java lwjgl GLSL shader issue with mac osx Validation Failed: No vertex array object bound : <p>I am building OPENGL application in Java using <a href="https://www.lwjgl.org/" rel="nofollow noreferrer">lwjgl</a> and following part of tutorial on YouTube by <a href="https://www.youtube.com/watch?v=DJnzafkmuTA&list=PLEETnX-uPtBXP_B2yupUKlflXBznWIlL5&index=9" rel="nofollow noreferrer">thebennybox</a></p>
<p>I am able to create rectangle using Mesh class i build. </p>
<pre><code>import engine.core.Util;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
public class Mesh {
private int vbo;
private int size;
public Mesh() {
this.vbo = glGenBuffers();
this.size = 0;
}
public void addVertices(Vertex[] vertices){
this.size = vertices.length * Vertex.SIZE;
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, Util.createFlippedBuffer(vertices), GL_STATIC_DRAW);
}
public void draw(){
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE * 4, 0);
glDrawArrays(GL_TRIANGLES, 0, this.size);
glDisableVertexAttribArray(0);
}
}
</code></pre>
<p>And <code>util</code> helper</p>
<pre><code>import engine.render.Vertex;
import org.lwjgl.BufferUtils;
import java.nio.FloatBuffer;
public class Util {
public static FloatBuffer createFloatBuffer(int size){
return BufferUtils.createFloatBuffer(size);
}
public static FloatBuffer createFlippedBuffer(Vertex[] vertices){
FloatBuffer buffer = createFloatBuffer(vertices.length * Vertex.SIZE);
for(int i = 0; i < vertices.length; i++) {
buffer.put(vertices[i].getPos().getX());
buffer.put(vertices[i].getPos().getY());
buffer.put(vertices[i].getPos().getZ());
}
buffer.flip();
return buffer;
}
}
</code></pre>
<p>Here is how i am rendering</p>
<pre><code> this.mesh = new Mesh();
Vertex[] data = new Vertex[]{
//1st triangle
new Vertex(new Vector3(0.5f,-0.5f,0)), //RB
new Vertex(new Vector3(-0.5f,-0.5f,0)), //LB
new Vertex(new Vector3(0.5f,0.5f,0)), //RT
//2nd triangle
new Vertex(new Vector3(-0.5f,0.5f,0)), //RB
new Vertex(new Vector3(0.5f,0.5f,0)), //RT
new Vertex(new Vector3(-0.5f,-0.5f,0)), //LB
};
mesh.addVertices(data);
public void render(){ //update per frame
mesh.draw();
}
</code></pre>
<p>So far it worked. Then I followed tutorial for shader and got error</p>
<blockquote>
<p>Validation Failed: No vertex array object bound.</p>
</blockquote>
<p>Here is shader class</p>
<pre><code>import static org.lwjgl.opengl.GL32C.*;
public class Shader {
private int program;
public Shader() {
program = glCreateProgram();
if(program == 0){
System.out.println("Shader creation failed!");
System.exit(1);
}
}
public void addVertexShader(String text){
//System.out.println(text);
addProgram(text, GL_VERTEX_SHADER);
}
public void addGeometryShader(String text){
addProgram(text, GL_GEOMETRY_SHADER);
}
public void addFragmentShader(String text){
addProgram(text, GL_FRAGMENT_SHADER);
}
public void bind(){
glUseProgram(program);
}
public void compileShader(){
glLinkProgram(program);
if(glGetProgrami(program, GL_LINK_STATUS) == 0){
System.out.println(glGetProgramInfoLog(program, 1024));
System.exit(1);
}
glValidateProgram(program);
if(glGetProgrami(program, GL_VALIDATE_STATUS) == 0){
// System.out.println("ffff");
System.out.println( glGetProgramInfoLog(program, 1024));
System.exit(1);
}
}
public void addProgram(String text, int type){
int shader = glCreateShader(type);
if(shader == 0){
System.out.println("Shader creation failed!");
System.exit(1);
}
glShaderSource(shader, text);
glCompileShader(shader);
if(glGetShaderi(shader, GL_COMPILE_STATUS) == 0){
System.out.println(glGetShaderInfoLog(shader, 1024));
System.exit(1);
}
glAttachShader(program, shader);
}
}
</code></pre>
<p>And here is ResourceLoader</p>
<pre><code> import java.io.BufferedReader;
import java.io.FileReader;
public class ResourceLoader {
public static String loadShader(String fileName){
StringBuilder shaderSource = new StringBuilder();
BufferedReader shaderReader = null;
try {
shaderReader = new BufferedReader(new FileReader(fileName));
String line;
while ((line = shaderReader.readLine()) != null){
shaderSource.append(line).append("\n");
}
} catch (Exception e){
System.out.println(e.getMessage());
}
return shaderSource.toString();
}
}
</code></pre>
<p>GLSL CODE FOR BOTH FILE</p>
<pre><code> ==== basicVertex.glsl
#version 410 core
out vec4 outColor;
void main(){
outColor = vec4(0.0, 1.0, 1.0, 1.0);
}
========= basicFragment.glsl
#version 410 core
layout (location = 0) in vec3 position;
void main(){
gl_Position = vec4(position, 1.0);
}
</code></pre>
| 0debug |
Swift UserDefaults : <p>I'm writing code for a game I am making and am trying to create a <code>User Default</code> so that it saves data after you close the app.</p>
<pre><code>let UserDefaults = NSUserDefaults.standardUserDefaults()
UserDefaults.setBool(false, forKey: "hasStarted")
</code></pre>
<p>But on the last line it underlines <code>UserDefaults</code> and says "expected declaration.</p>
<p>What have I done wrong?</p>
| 0debug |
Java scanner NullPointerException : <p>i'm trying to make my scanner do some basic console interface, but it keeps returning NullPointerException no matter what i try.
Here is the some of code:</p>
<pre><code>public static void main(String[] args) {
list nlist = new list();
Scanner menu_input = null;
[..] //a couple println here...
opt = menu_input.nextInt(); //the error points to this line
switch (opt) { ... }
</code></pre>
<p>why would it cause an error like this?
I'm sorry if this is trivial, but this is my first real experience with Java.</p>
<p>Full text of the error in case it's useful:</p>
<pre><code>Exception in thread "main" java.lang.NullPointerException
at lab.newJava.main(newJava.java:75)
</code></pre>
| 0debug |
void pci_register_bar(PCIDevice *pci_dev, int region_num,
pcibus_t size, int type,
PCIMapIORegionFunc *map_func)
{
PCIIORegion *r;
uint32_t addr;
uint64_t wmask;
if ((unsigned int)region_num >= PCI_NUM_REGIONS)
return;
if (size & (size-1)) {
fprintf(stderr, "ERROR: PCI region size must be pow2 "
"type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
exit(1);
}
r = &pci_dev->io_regions[region_num];
r->addr = PCI_BAR_UNMAPPED;
r->size = size;
r->filtered_size = size;
r->type = type;
r->map_func = map_func;
wmask = ~(size - 1);
addr = pci_bar(pci_dev, region_num);
if (region_num == PCI_ROM_SLOT) {
wmask |= PCI_ROM_ADDRESS_ENABLE;
}
pci_set_long(pci_dev->config + addr, type);
if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO) &&
r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) {
pci_set_quad(pci_dev->wmask + addr, wmask);
pci_set_quad(pci_dev->cmask + addr, ~0ULL);
} else {
pci_set_long(pci_dev->wmask + addr, wmask & 0xffffffff);
pci_set_long(pci_dev->cmask + addr, 0xffffffff);
}
}
| 1threat |
static void virtio_scsi_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = virtio_scsi_device_exit;
dc->props = virtio_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->init = virtio_scsi_device_init;
vdc->set_config = virtio_scsi_set_config;
vdc->get_features = virtio_scsi_get_features;
vdc->reset = virtio_scsi_reset;
}
| 1threat |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.