rem
stringlengths 0
274k
| add
stringlengths 0
169k
| context
stringlengths 9
471k
|
---|---|---|
return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST); | return( _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST) ); | rtems_status_code rtems_message_queue_send( Objects_Id id, void *buffer, unsigned32 size){ return _Message_queue_Submit(id, buffer, size, MESSAGE_QUEUE_SEND_REQUEST);} |
if ( the_message_queue->number_of_pending_messages != 0 ) (void) _Message_queue_Flush_support( the_message_queue ); else _Thread_queue_Flush( &the_message_queue->Wait_queue, _Message_queue_MP_Send_object_was_deleted, RTEMS_OBJECT_WAS_DELETED ); | _CORE_message_queue_Close( &the_message_queue->message_queue, _Message_queue_MP_Send_object_was_deleted, CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED ); | rtems_status_code rtems_message_queue_delete( Objects_Id id){ register Message_queue_Control *the_message_queue; Objects_Locations location; the_message_queue = _Message_queue_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return RTEMS_INVALID_ID; case OBJECTS_REMOTE: _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; case OBJECTS_LOCAL: _Objects_Close( &_Message_queue_Information, &the_message_queue->Object ); if ( the_message_queue->number_of_pending_messages != 0 ) (void) _Message_queue_Flush_support( the_message_queue ); else _Thread_queue_Flush( &the_message_queue->Wait_queue, _Message_queue_MP_Send_object_was_deleted, RTEMS_OBJECT_WAS_DELETED ); _Message_queue_Free( the_message_queue ); if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) { _Objects_MP_Close( &_Message_queue_Information, the_message_queue->Object.id ); _Message_queue_MP_Send_process_packet( MESSAGE_QUEUE_MP_ANNOUNCE_DELETE, the_message_queue->Object.id, 0, /* Not used */ 0 ); } _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */} |
case PPC_604r: return "MPC604r"; | SPR_RO(PVR)ppc_cpu_id_t current_ppc_cpu = PPC_UNKNOWN;ppc_cpu_revision_t current_ppc_revision = 0xff;char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu){ switch (cpu) { case PPC_601: return "MPC601"; case PPC_603: return "MPC603"; case PPC_603ev: return "MPC603ev"; case PPC_604: return "MPC604"; /* case PPC_604r: return "MPC604r"; same value as 750 */ case PPC_750: return "MPC750"; case PPC_7400: return "MPC7400"; case PPC_604e: return "MPC604e"; case PPC_620: return "MPC620"; case PPC_860: return "MPC860"; case PPC_8260: return "MPC8260"; default: printk("Unknown CPU value of 0x%x. Please add it to <libcpu/powerpc/shared/cpu.h>\n", cpu ); } return "UNKNOWN";} |
|
gpui(pitemp,gneg(s),prec)); | gpow(pitemp,gneg(s),prec)); | czeta(GEN s0, long prec){ GEN s, u, a, y, res, tes, sig, invn2, p1, unr; GEN sim, ms, s1, s2, s3, s4, s5, *tab, tabn; long p, i, sqn, nn, lim, lim2, ct; pari_sp av, av2 = avma, avlim; int funeq = 0; byteptr d; if (DEBUGLEVEL>2) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (gcmp0(s)) { y = gneg(ghalf); goto END; } if (signe(sig) <= 0 || expo(sig) < -1) { /* s <--> 1-s */ if (typ(s0) == t_INT) { p = itos(s0); avma = av2; return izeta(p,prec); } funeq = 1; s = gsub(gun, s); sig = greal(s); } if (gcmp(sig, stoi(bit_accuracy(prec) + 1)) > 0) { y = gun; goto END; } { /* find "optimal" parameters [lim, nn] */ double ssig = rtodbl(sig); double st = rtodbl(gimag(s)); double ns = dnorm(ssig,st), l,l2; long la = 1; if (typ(s0) == t_INT) { long ss = itos(s0); switch(ss) { /* should depend on prec ? */ case 3: la = 6; break; default: la = 3; break; } } if (dnorm(ssig-1,st) < 0.1) /* |s - 1| < 0.1 */ l2 = -(ssig - 0.5); else { /* l2 = Re( (s - 1/2) log (s-1) ) */ double rlog, ilog; /* log(s-1) */ dcxlog(ssig-1,st, &rlog,&ilog); l2 = (ssig - 0.5)*rlog - st*ilog; } l = (pariC2*(prec-2) - l2 + ssig*2*pariC1) / (2. * (1.+ log((double)la))); l2 = sqrt(ns)/2; if (l < l2) l = l2; lim = (long) ceil(l); if (lim < 2) lim = 2; l2 = (lim+ssig/2.-.25); nn = 1 + (long)ceil( sqrt(l2*l2 + st*st/4) * la / PI ); if (DEBUGLEVEL>2) fprintferr("lim, nn: [%ld, %ld]\n",lim,nn); maxprime_check((ulong)nn); } prec++; unr = realun(prec); /* one extra word of precision */ tab = (GEN*)cgetg(nn, t_VEC); /* table of q^(-s), q = p^e */ d = diffptr + 1; if (typ(s0) == t_INT) { /* no explog for 1/p^s */ for (p=2; p < nn;) { tab[p] = divrr(unr, rpowsi(p, s0, prec)); NEXT_PRIME_VIADIFF(p,d); } a = divrr(unr, rpowsi(nn, s0, prec)); } else { /* general case */ ms = gneg(s); p1 = cgetr(prec); for (p=2; p < nn;) { affsr(p, p1); tab[p] = gexp(gmul(ms, mplog(p1)), prec); NEXT_PRIME_VIADIFF(p,d); } affsr(nn,p1); a = gexp(gmul(ms, mplog(p1)), prec); } sqn = (long)sqrt(nn-1.); d = diffptr + 2; /* fill in odd prime powers */ maxprime_check(sqn); for (p=3; p <= sqn; ) { ulong oldq = p, q = p*p; while (q<(ulong)nn) { tab[q] = gmul(tab[p], tab[oldq]); oldq = q; q *= p; } NEXT_PRIME_VIADIFF(p,d); } if (DEBUGLEVEL>2) msgtimer("tab[q^-s] from 1 to N-1"); tabn = cgetg(nn, t_VECSMALL); ct = 0; for (i = nn-1; i; i>>=1) tabn[++ct] = (i-1)>>1; sim = y = unr; for (i=ct; i > 1; i--) { long j; pari_sp av2 = avma; for (j=tabn[i]+1; j<=tabn[i-1]; j++) sim = gadd(sim, n_s(2*j+1, tab)); sim = gerepileupto(av2, sim); y = gadd(sim, gmul(tab[2],y)); } y = gadd(y, gmul2n(a,-1)); if (DEBUGLEVEL>2) msgtimer("sum from 1 to N-1"); invn2 = divrs(unr, nn*nn); lim2 = lim<<1; tes = bernreal(lim2, prec); if (typ(s0) == t_INT) { av2 = avma; avlim = stack_lim(av2,3); for (i=lim2-2; i>=2; i-=2) { /* using single prec (when (s0 + i) < 2^31) not faster (even at \p28) */ u = mulri(mulrr(tes,invn2), mulii(addsi(i,s0), addsi(i-1,s0))); tes = addrr(bernreal(i,prec), divrs2_safe(u, i+1)); /* u / (i+1)(i+2) */ if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"czeta"); tes = gerepileuptoleaf(av2, tes); } } u = gmul(gmul(tes,invn2), gmul2n(mulii(s0, addsi(-1,s0)), -1)); tes = gmulsg(nn, gaddsg(1, u)); } else /* typ(s0) != t_INT */ { s1 = gsub(gmul2n(s,1), unr); s2 = gmul(s, gsub(s,unr)); s3 = gmul2n(invn2,3); av2 = avma; avlim = stack_lim(av2,3); s4 = gmul(invn2, gmul2n(gaddsg(4*lim-2,s1),1)); s5 = gmul(invn2, gadd(s2, gmulsg(lim2, gaddgs(s1, lim2)))); for (i = lim2-2; i>=2; i -= 2) { s5 = gsub(s5, s4); s4 = gsub(s4, s3); tes = gadd(bernreal(i,prec), gdivgs(gmul(s5,tes), (i+1)*(i+2))); if (low_stack(avlim,stack_lim(av2,3))) { GEN *gptr[3]; gptr[0]=&tes; gptr[1]=&s5; gptr[2]=&s4; if(DEBUGMEM>1) err(warnmem,"czeta"); gerepilemany(av2,gptr,3); } } u = gmul(gmul(tes,invn2), gmul2n(s2, -1)); tes = gmulsg(nn, gaddsg(1, u)); } if (DEBUGLEVEL>2) msgtimer("Bernoulli sum"); /* y += tes a / (s-1) */ y = gadd(y, gmul(tes, gdiv(a, gsub(s, unr))));END: if (funeq) { GEN pitemp = mppi(prec); setexpo(pitemp,2); /* 2Pi */ y = gmul(gmul(y, ggamma(gprec_w(s,prec-1),prec)), gpui(pitemp,gneg(s),prec)); setexpo(pitemp,0); /* Pi/2 */ y = gmul2n(gmul(y, gcos(gmul(pitemp,s),prec)), 1); } gaffect(y,res); avma = av; return res;} |
unsigned32 start, unsigned32 offset, unsigned32 count, | uint32_t start, uint32_t offset, uint32_t count, | _fat_block_read( rtems_filesystem_mount_table_entry_t *mt_entry, unsigned32 start, unsigned32 offset, unsigned32 count, void *buff ){ int rc = RC_OK; register fat_fs_info_t *fs_info = mt_entry->fs_info; ssize_t cmpltd = 0; unsigned32 blk = start; unsigned32 ofs = offset; bdbuf_buffer *block = NULL; unsigned32 c = 0; while (count > 0) { rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_READ, &block); if (rc != RC_OK) return -1; c = MIN(count, (fs_info->vol.bps - ofs)); memcpy((buff + cmpltd), (block->buffer + ofs), c); count -= c; cmpltd += c; blk++; ofs = 0; } return cmpltd;} |
unsigned32 blk = start; unsigned32 ofs = offset; | uint32_t blk = start; uint32_t ofs = offset; | _fat_block_read( rtems_filesystem_mount_table_entry_t *mt_entry, unsigned32 start, unsigned32 offset, unsigned32 count, void *buff ){ int rc = RC_OK; register fat_fs_info_t *fs_info = mt_entry->fs_info; ssize_t cmpltd = 0; unsigned32 blk = start; unsigned32 ofs = offset; bdbuf_buffer *block = NULL; unsigned32 c = 0; while (count > 0) { rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_READ, &block); if (rc != RC_OK) return -1; c = MIN(count, (fs_info->vol.bps - ofs)); memcpy((buff + cmpltd), (block->buffer + ofs), c); count -= c; cmpltd += c; blk++; ofs = 0; } return cmpltd;} |
unsigned32 c = 0; | uint32_t c = 0; | _fat_block_read( rtems_filesystem_mount_table_entry_t *mt_entry, unsigned32 start, unsigned32 offset, unsigned32 count, void *buff ){ int rc = RC_OK; register fat_fs_info_t *fs_info = mt_entry->fs_info; ssize_t cmpltd = 0; unsigned32 blk = start; unsigned32 ofs = offset; bdbuf_buffer *block = NULL; unsigned32 c = 0; while (count > 0) { rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_READ, &block); if (rc != RC_OK) return -1; c = MIN(count, (fs_info->vol.bps - ofs)); memcpy((buff + cmpltd), (block->buffer + ofs), c); count -= c; cmpltd += c; blk++; ofs = 0; } return cmpltd;} |
tabaall = (GEN*)cgetg(lv,t_VECSMALL); tabtall = (GEN*)cgetg(lv,t_VECSMALL); | tabaall = (GEN*)cgetg(lv,t_VEC); tabtall = (GEN*)cgetg(lv,t_VEC); | inittabs(int lv){ int i; tabaall = (GEN*)cgetg(lv,t_VECSMALL); tabtall = (GEN*)cgetg(lv,t_VECSMALL); tabcyc = (GEN*)cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabcyc[i] = gzero; tabE = cgetg(lv,t_VEC); tabTH= cgetg(lv,t_VEC); tabeta=cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabE[i] = tabTH[i] = tabeta[i] = zero; sgt = cgetg(lv,t_VECSMALL); ctsgt= cgetg(lv,t_VECSMALL); for (i=1; i<lv; i++) sgt[i] = ctsgt[i] = 0;} |
for (i=1; i<lv; i++) tabE[i] = tabTH[i] = tabeta[i] = zero; | tabmatvite = (GEN*)cgetg(lv,t_VEC); tabmatinvvite = (GEN*)cgetg(lv,t_VEC); tabavite = cgetg(lv,t_VEC); tabpkvite = cgetg(lv,t_VECSMALL); for (i=1; i<lv; i++) { tabE[i] = tabTH[i] = tabeta[i] = tabavite[i] = zero; tabmatvite[i] = tabmatinvvite[i] = gzero; } | inittabs(int lv){ int i; tabaall = (GEN*)cgetg(lv,t_VECSMALL); tabtall = (GEN*)cgetg(lv,t_VECSMALL); tabcyc = (GEN*)cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabcyc[i] = gzero; tabE = cgetg(lv,t_VEC); tabTH= cgetg(lv,t_VEC); tabeta=cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabE[i] = tabTH[i] = tabeta[i] = zero; sgt = cgetg(lv,t_VECSMALL); ctsgt= cgetg(lv,t_VECSMALL); for (i=1; i<lv; i++) sgt[i] = ctsgt[i] = 0;} |
for (i=1; i<lv; i++) sgt[i] = ctsgt[i] = 0; | for (i=1; i<lv; i++) tabpkvite[i] = sgt[i] = ctsgt[i] = 0; | inittabs(int lv){ int i; tabaall = (GEN*)cgetg(lv,t_VECSMALL); tabtall = (GEN*)cgetg(lv,t_VECSMALL); tabcyc = (GEN*)cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabcyc[i] = gzero; tabE = cgetg(lv,t_VEC); tabTH= cgetg(lv,t_VEC); tabeta=cgetg(lv,t_VEC); for (i=1; i<lv; i++) tabE[i] = tabTH[i] = tabeta[i] = zero; sgt = cgetg(lv,t_VECSMALL); ctsgt= cgetg(lv,t_VECSMALL); for (i=1; i<lv; i++) sgt[i] = ctsgt[i] = 0;} |
ctx->chunked = 1; | static apr_status_t run_machine(serf_bucket_t *bkt, response_context_t *ctx){ apr_status_t status = APR_SUCCESS; /* initialize to avoid gcc warnings */ switch (ctx->state) { case STATE_STATUS_LINE: /* RFC 2616 says that CRLF is the only line ending, but we can easily * accept any kind of line ending. */ status = fetch_line(ctx, SERF_NEWLINE_ANY); if (SERF_BUCKET_READ_ERROR(status)) return status; if (ctx->linebuf.state == SERF_LINEBUF_READY) { /* The Status-Line is in the line buffer. Process it. */ status = parse_status_line(ctx, bkt->allocator); if (status) return status; /* Okay... move on to reading the headers. */ ctx->state = STATE_HEADERS; } break; case STATE_HEADERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we hit the end of the headers. * Move on to the body. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { const void *v; /* Are we C-L, chunked, or conn close? */ v = serf_bucket_headers_get(ctx->headers, "Content-Length"); if (v) { apr_size_t length; length = apr_strtoi64(v, NULL, 10); if (errno == ERANGE) { return APR_FROM_OS_ERROR(ERANGE); } ctx->body = serf_bucket_limit_create(ctx->stream, length, bkt->allocator); } else { v = serf_bucket_headers_get(ctx->headers, "Transfer-Encoding"); /* Need to handle multiple transfer-encoding. */ if (v && strcasecmp("chunked", v) == 0) { ctx->body = serf_bucket_dechunk_create(ctx->stream, bkt->allocator); } /* Connection: Close response. */ /* FIXME There is a problem that arises here due to bucket * ownership. If we were to get a Conn: Close with gzip * encoding, we'll get a double free and abort(). * * The reason is that the deflate bucket assumes that its * streams are of the same lifetime. However, the dechunk * and limit buckets assume that its streams are of * different lifetimes. This isn't quite right and needs * to be rethought. */ if (!ctx->body) { ctx->body = ctx->stream; } } v = serf_bucket_headers_get(ctx->headers, "Content-Encoding"); if (v) { /* Need to handle multiple content-encoding. */ if (v && strcasecmp("gzip", v) == 0) { ctx->body = serf_bucket_deflate_create(ctx->body, bkt->allocator); } } ctx->state = STATE_BODY; } break; case STATE_BODY: /* Don't do anything. */ break; case STATE_TRAILERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we're done. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { ctx->state = STATE_DONE; return APR_EOF; } break; case STATE_DONE: return APR_EOF; default: abort(); } return status;} |
|
long n=lg(L), deg=gf->deg; | long n=lg(L)-1, deg=gf->deg; | galoisfrobeniuslift(GEN T, GEN den, GEN L, GEN Lden, long gmask, struct galois_frobenius *gf, struct galois_borne *gb) { ulong ltop=avma,lbot,av2; struct galois_testlift gt; struct galois_lift gl; GEN frob,tower,res=NULL; long i,j,k,l; long n=lg(L), deg=gf->deg; long way;/*from home*/ GEN *gptr[3]; GEN ip=stoi(gf->p), aut; if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:p=%ld deg=%ld fp=%ld\n", gf->p, deg, gf->fp); frob = cgetg(lg(L), t_VECSMALL); av2=avma; initlift(T, den, ip, L, Lden, gb, &gl); aut = galoisdolift(&gl, frob); if (!aut || galoisfrobeniustest(aut,&gl,frob)) { avma=av2; gf->deg = gf->fp; gf->sg = cgetg(2, t_VECSMALL); gf->sg[1]=1; gf->psi = cgetg(lg(gf->Tmod), t_VECSMALL); for (k = 1; k <lg(gf->Tmod); k++) gf->psi[k] = 1; return frob; } inittestlift(aut,gf->Tmod, &gl, >); gt.C=cgetg(gf->fp+1,t_VEC); for (i = 1; i <= gf->fp; i++) { gt.C[i]=lgetg(gt.g+1,t_VECSMALL); for(j = 1; j <= gt.g; j++) mael(gt.C,i,j)=0; } gt.Cd=gcopy(gt.C); for (way=0;way<=1;way++) if((gmask&(1<<way)) && gf->fp%(way?2:deg) == 0) { tower=galoistowerprime(stoi(gf->fp),!way); for(k=lg(tower)-2;k>=1+way;k--) { GEN lo; GEN psi; long el=tower[k], dg=gf->fp/tower[k]; if ( DEBUGLEVEL>=4 ) fprintferr("Trying degre %d.\n",dg); if (galoisfrobeniustest((GEN)gt.pauto[el+1],&gl,frob)) { gf->deg=dg; gf->sg = cgetg(2, t_VECSMALL); gf->sg[1]=1; gf->psi = cgetg(gt.g + 1, t_VECSMALL); for (i = 1; i <= gt.g; i++) gf->psi[i] = 1; res=gcopy(frob); continue; } disable_dbg(0); lo = listsousgroupes(dg, n / gf->fp); disable_dbg(-1); if (k!=lg(tower)-2) lo = galoisfindgroups(lo, gf->sg, gf->deg); if (DEBUGLEVEL >= 4) fprintferr("Galoisconj:Subgroups list:%Z\n", lo); for (l = 1; l < lg(lo); l++) if ( lg(lo[l])>2 && frobeniusliftall((GEN)lo[l], el, &psi, &gl, >, frob)) break; if ( l == lg(lo) ) break; gf->sg=(GEN)lo[l]; gf->psi=psi; gf->deg=dg; res=gcopy(frob); } if (res) break; } for (i = 1; i <= gf->fp; i++) for (j = 1; j <= gt.g; j++) if (mael(gt.C,i,j)) gunclone(gmael(gt.C,i,j)); if (DEBUGLEVEL>=4 && res) fprintferr("Best lift: %d\n",gf->deg); if (!res) { avma=ltop; return NULL; } lbot=avma; gf->sg=gcopy(gf->sg); gf->psi=gcopy(gf->psi); res=gcopy(res); gptr[0]=&gf->sg; gptr[1]=&gf->psi; gptr[2]=&res; gerepilemanysp(ltop,lbot,gptr,3); return res;} |
return( RTEMS_INVALID_ID ); | return RTEMS_INVALID_ID; | rtems_status_code rtems_semaphore_delete( Objects_Id id){ register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: _Thread_Dispatch(); return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); case OBJECTS_LOCAL: if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { _Thread_Enable_dispatch(); return( RTEMS_RESOURCE_IN_USE ); } else _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _Semaphore_MP_Send_object_was_deleted, CORE_MUTEX_WAS_DELETED ); } else _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, CORE_SEMAPHORE_WAS_DELETED ); _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); _Semaphore_Free( the_semaphore ); if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) { _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id ); _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_DELETE, the_semaphore->Object.id, 0, /* Not used */ 0 /* Not used */ ); } _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL ); } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); | return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; | rtems_status_code rtems_semaphore_delete( Objects_Id id){ register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: _Thread_Dispatch(); return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); case OBJECTS_LOCAL: if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { _Thread_Enable_dispatch(); return( RTEMS_RESOURCE_IN_USE ); } else _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _Semaphore_MP_Send_object_was_deleted, CORE_MUTEX_WAS_DELETED ); } else _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, CORE_SEMAPHORE_WAS_DELETED ); _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); _Semaphore_Free( the_semaphore ); if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) { _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id ); _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_DELETE, the_semaphore->Object.id, 0, /* Not used */ 0 /* Not used */ ); } _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL ); } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( RTEMS_RESOURCE_IN_USE ); | return RTEMS_RESOURCE_IN_USE; | rtems_status_code rtems_semaphore_delete( Objects_Id id){ register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: _Thread_Dispatch(); return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); case OBJECTS_LOCAL: if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { _Thread_Enable_dispatch(); return( RTEMS_RESOURCE_IN_USE ); } else _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _Semaphore_MP_Send_object_was_deleted, CORE_MUTEX_WAS_DELETED ); } else _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, CORE_SEMAPHORE_WAS_DELETED ); _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); _Semaphore_Free( the_semaphore ); if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) { _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id ); _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_DELETE, the_semaphore->Object.id, 0, /* Not used */ 0 /* Not used */ ); } _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL ); } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( RTEMS_SUCCESSFUL ); | return RTEMS_SUCCESSFUL; | rtems_status_code rtems_semaphore_delete( Objects_Id id){ register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: _Thread_Dispatch(); return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); case OBJECTS_LOCAL: if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { _Thread_Enable_dispatch(); return( RTEMS_RESOURCE_IN_USE ); } else _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _Semaphore_MP_Send_object_was_deleted, CORE_MUTEX_WAS_DELETED ); } else _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, CORE_SEMAPHORE_WAS_DELETED ); _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); _Semaphore_Free( the_semaphore ); if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) { _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id ); _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_DELETE, the_semaphore->Object.id, 0, /* Not used */ 0 /* Not used */ ); } _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL ); } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( RTEMS_INTERNAL_ERROR ); | return RTEMS_INTERNAL_ERROR; | rtems_status_code rtems_semaphore_delete( Objects_Id id){ register Semaphore_Control *the_semaphore; Objects_Locations location; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: _Thread_Dispatch(); return( RTEMS_ILLEGAL_ON_REMOTE_OBJECT ); case OBJECTS_LOCAL: if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set) ) { if ( _CORE_mutex_Is_locked( &the_semaphore->Core_control.mutex ) ) { _Thread_Enable_dispatch(); return( RTEMS_RESOURCE_IN_USE ); } else _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _Semaphore_MP_Send_object_was_deleted, CORE_MUTEX_WAS_DELETED ); } else _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, CORE_SEMAPHORE_WAS_DELETED ); _Objects_Close( &_Semaphore_Information, &the_semaphore->Object ); _Semaphore_Free( the_semaphore ); if ( _Attributes_Is_global( the_semaphore->attribute_set ) ) { _Objects_MP_Close( &_Semaphore_Information, the_semaphore->Object.id ); _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_DELETE, the_semaphore->Object.id, 0, /* Not used */ 0 /* Not used */ ); } _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL ); } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return ( RTEMS_INVALID_NAME ); | return RTEMS_INVALID_NAME; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_MP_NOT_CONFIGURED ); | return RTEMS_MP_NOT_CONFIGURED; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_NOT_DEFINED ); | return RTEMS_NOT_DEFINED; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_INVALID_NUMBER ); | return RTEMS_INVALID_NUMBER; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_TOO_MANY ); | return RTEMS_TOO_MANY; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_SUCCESSFUL ); | return RTEMS_SUCCESSFUL; | rtems_status_code rtems_semaphore_create( rtems_name name, unsigned32 count, rtems_attribute attribute_set, rtems_task_priority priority_ceiling, Objects_Id *id){ register Semaphore_Control *the_semaphore; CORE_mutex_Attributes the_mutex_attributes; CORE_semaphore_Attributes the_semaphore_attributes; unsigned32 lock; if ( !rtems_is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( _Attributes_Is_global( attribute_set ) ) { if ( !_System_state_Is_multiprocessing ) return( RTEMS_MP_NOT_CONFIGURED ); if ( _Attributes_Is_inherit_priority( attribute_set ) ) return( RTEMS_NOT_DEFINED ); } else if ( _Attributes_Is_inherit_priority( attribute_set ) ) { if ( ! ( _Attributes_Is_binary_semaphore( attribute_set ) && _Attributes_Is_priority( attribute_set ) ) ) return( RTEMS_NOT_DEFINED ); } if ( _Attributes_Is_binary_semaphore( attribute_set ) && ( count > 1 ) ) return( RTEMS_INVALID_NUMBER ); _Thread_Disable_dispatch(); /* prevents deletion */ the_semaphore = _Semaphore_Allocate(); if ( !the_semaphore ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && ! ( _Objects_MP_Allocate_and_open( &_Semaphore_Information, name, the_semaphore->Object.id, FALSE ) ) ) { _Semaphore_Free( the_semaphore ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_semaphore->attribute_set = attribute_set; if ( _Attributes_Is_binary_semaphore( attribute_set ) ) { if ( _Attributes_Is_inherit_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; else if (_Attributes_Is_priority_ceiling( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; else if (_Attributes_Is_priority( attribute_set ) ) the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_PRIORITY; else the_mutex_attributes.discipline = CORE_MUTEX_DISCIPLINES_FIFO; the_mutex_attributes.allow_nesting = TRUE; /* Add priority ceiling code here ????? */ if ( count == 1 ) lock = CORE_MUTEX_UNLOCKED; else lock = CORE_MUTEX_LOCKED; _CORE_mutex_Initialize( &the_semaphore->Core_control.mutex, OBJECTS_RTEMS_SEMAPHORES, &the_mutex_attributes, lock, _Semaphore_MP_Send_extract_proxy ); } else { if ( _Attributes_Is_priority( attribute_set ) ) the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY; else the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; _CORE_semaphore_Initialize( &the_semaphore->Core_control.semaphore, OBJECTS_RTEMS_SEMAPHORES, &the_semaphore_attributes, count, _Semaphore_MP_Send_extract_proxy ); } _Objects_Open( &_Semaphore_Information, &the_semaphore->Object, &name ); *id = the_semaphore->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Semaphore_MP_Send_process_packet( SEMAPHORE_MP_ANNOUNCE_CREATE, the_semaphore->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );} |
return( RTEMS_INVALID_ID ); | return RTEMS_INVALID_ID; | rtems_status_code rtems_semaphore_obtain( Objects_Id id, unsigned32 option_set, rtems_interval timeout){ register Semaphore_Control *the_semaphore; Objects_Locations location; boolean wait; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: return _Semaphore_MP_Send_request_packet( SEMAPHORE_MP_OBTAIN_REQUEST, id, option_set, timeout ); case OBJECTS_LOCAL: if ( _Options_Is_no_wait( option_set ) ) wait = FALSE; else wait = TRUE; if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) { _CORE_mutex_Seize( &the_semaphore->Core_control.mutex, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ) ); } else { _CORE_semaphore_Seize( &the_semaphore->Core_control.semaphore, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ) ); } } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ) ); | return _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ); | rtems_status_code rtems_semaphore_obtain( Objects_Id id, unsigned32 option_set, rtems_interval timeout){ register Semaphore_Control *the_semaphore; Objects_Locations location; boolean wait; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: return _Semaphore_MP_Send_request_packet( SEMAPHORE_MP_OBTAIN_REQUEST, id, option_set, timeout ); case OBJECTS_LOCAL: if ( _Options_Is_no_wait( option_set ) ) wait = FALSE; else wait = TRUE; if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) { _CORE_mutex_Seize( &the_semaphore->Core_control.mutex, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ) ); } else { _CORE_semaphore_Seize( &the_semaphore->Core_control.semaphore, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ) ); } } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ) ); | return _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ); | rtems_status_code rtems_semaphore_obtain( Objects_Id id, unsigned32 option_set, rtems_interval timeout){ register Semaphore_Control *the_semaphore; Objects_Locations location; boolean wait; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: return _Semaphore_MP_Send_request_packet( SEMAPHORE_MP_OBTAIN_REQUEST, id, option_set, timeout ); case OBJECTS_LOCAL: if ( _Options_Is_no_wait( option_set ) ) wait = FALSE; else wait = TRUE; if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) { _CORE_mutex_Seize( &the_semaphore->Core_control.mutex, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ) ); } else { _CORE_semaphore_Seize( &the_semaphore->Core_control.semaphore, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ) ); } } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
return( RTEMS_INTERNAL_ERROR ); | return RTEMS_INTERNAL_ERROR; | rtems_status_code rtems_semaphore_obtain( Objects_Id id, unsigned32 option_set, rtems_interval timeout){ register Semaphore_Control *the_semaphore; Objects_Locations location; boolean wait; the_semaphore = _Semaphore_Get( id, &location ); switch ( location ) { case OBJECTS_ERROR: return( RTEMS_INVALID_ID ); case OBJECTS_REMOTE: return _Semaphore_MP_Send_request_packet( SEMAPHORE_MP_OBTAIN_REQUEST, id, option_set, timeout ); case OBJECTS_LOCAL: if ( _Options_Is_no_wait( option_set ) ) wait = FALSE; else wait = TRUE; if ( _Attributes_Is_binary_semaphore( the_semaphore->attribute_set ) ) { _CORE_mutex_Seize( &the_semaphore->Core_control.mutex, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_mutex_return_code( _Thread_Executing->Wait.return_code ) ); } else { _CORE_semaphore_Seize( &the_semaphore->Core_control.semaphore, id, wait, timeout ); _Thread_Enable_dispatch(); return( _Semaphore_Translate_core_semaphore_return_code( _Thread_Executing->Wait.return_code ) ); } } return( RTEMS_INTERNAL_ERROR ); /* unreached - only to remove warnings */} |
if (*a <= P) prime[2] = sinitp(*a, 0, &p); if (*b > P) err(primer1); | if ((ulong)*a <= P) prime[2] = sinitp(*a, 0, &p); if ((ulong)*b > P) err(primer1); | prime_loop_init(GEN ga, GEN gb, long *a, long *b, long prime[]){ byteptr p = diffptr; ulong P; ga = gceil(ga); gb = gfloor(gb); if (typ(ga) != t_INT || typ(gb) != t_INT) err(typeer,"prime_loop_init"); if (is_bigint(ga) || is_bigint(gb)) { if (cmpii(ga, gb) > 0) return NULL; err(primer1); } P = maxprime(); *a = itos(ga); if (*a <= 0) *a = 1; *b = itos(gb); if (*a > *b) return NULL; if (*a <= P) prime[2] = sinitp(*a, 0, &p); if (*b > P) err(primer1); return p;} |
static_OBJ = checknf(nf); return _factorback(fa, e, &eltmul, &eltpow); | nf = checknf(nf); return _factorback(fa, e, &eltmul, &eltpow, nf); | factorbackelt(GEN fa, GEN e, GEN nf){ if (!nf && e && lg(e) > 1 && typ(e[1]) != t_INT) { nf = e; e = NULL; } if (!nf) err(talker, "missing nf in factorbackelt"); static_OBJ = checknf(nf); return _factorback(fa, e, &eltmul, &eltpow);} |
printf( "....st_ino %x\n", buf->st_ino ); | printf( "....st_ino %x may vary by small amount\n", (unsigned int) buf->st_ino ); | void dump_statbuf( struct stat *buf ){ int major1; int minor1; int major2; int minor2; rtems_filesystem_split_dev_t( buf->st_dev, major1, minor1 ); rtems_filesystem_split_dev_t( buf->st_rdev, major2, minor2 ); printf( "....st_dev (0x%x:0x%x)\n", major1, minor1 ); printf( "....st_ino %x\n", buf->st_ino ); printf( "....mode = %08o\n", buf->st_mode ); printf( "....nlink = %d\n", buf->st_nlink ); printf( "....uid = %d\n", buf->st_uid ); printf( "....gid = %d\n", buf->st_gid ); printf( "....atime = %s", ctime(&buf->st_atime) ); printf( "....mtime = %s", ctime(&buf->st_mtime) ); printf( "....ctime = %s", ctime(&buf->st_ctime) );#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) printf( "....st_blksize %x\n", buf.st_blksize ); printf( "....st_blocks %x\n", buf.st_blocks );#endif} |
x %= y1; if (x < 0) x += y1; | x = x % (long)y1; if (x < 0) x += y1; | kross(long x, long y){ ulong y1; long s = 1, r; if (y <= 0) { if (y == 0) return (labs(x)==1); y1 = (ulong)-y; if (x < 0) s = -1; } else y1 = (ulong)y; r = vals(y1); if (r) { if (!odd(x)) return 0; if (odd(r) && ome(x)) s = -s; y1 >>= r; } x %= y1; if (x < 0) x += y1; return krouu((ulong)x, y1, s);} |
long m,i,j,ltop=avma, av, lim=stack_lim(av,1), vx = varn(x); | long m,i,j,ltop=avma, av, lim=stack_lim(avma,1), vx = varn(x); | Fp_pow_mod_pol(GEN x, GEN n, GEN pol, GEN p){ long m,i,j,ltop=avma, av, lim=stack_lim(av,1), vx = varn(x); GEN p1 = n+2, y; if (!signe(n)) return polun[vx]; if (signe(n)<0) { x=Fp_inv_mod_pol(x,pol,p); if (is_pm1(n)) return x;/*n=-1*/ } else if (is_pm1(n)) return gcopy(x);/*n=1*/ m = *p1; y = x; av=avma; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = Fp_sqr_mod_pol(y,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } if (m<0) y = Fp_mul_mod_pol(y,x,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } } if (--i == 0) break; m = *++p1, j = BITS_IN_LONG; } return gerepileupto(ltop,y);} |
unsigned32 old_level; | uint32_t old_level; | void DEBUG_puts( char *string){ char *s; unsigned32 old_level; ERC32_Disable_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level ); for ( s = string ; *s ; s++ ) console_outbyte_polled( 0, *s ); console_outbyte_polled( 0, '\r' ); console_outbyte_polled( 0, '\n' ); ERC32_Restore_interrupt( ERC32_INTERRUPT_UART_A_RX_TX, old_level );} |
GEN w, wpow, wnew, ma = tabmatvite[pkfalse]; | GEN w, ma = tabmatvite[pkfalse]; | _powpolmodsimple(red_t *R, int pk, GEN jac){ GEN w, wpow, wnew, ma = tabmatvite[pkfalse]; int j, ph = lg(ma); w = mulmat_pol(ma, jac); w = FpV_red(w, R->N); R->red = &_redsimple; wpow = cgetg(ph,t_COL); for (j=1; j<ph; j++) wpow[j] = (long)_powpolmod(pk, (GEN)w[j], R, &sqrmod); wnew = FpV_red( gmul(tabmatinvvite[pkfalse], wpow), R->N ); return gtopoly(wnew,0);} |
w = FpV_red(w, R->N); R->red = &_redsimple; wpow = cgetg(ph,t_COL); for (j=1; j<ph; j++) wpow[j] = (long)_powpolmod(pk, (GEN)w[j], R, &sqrmod); wnew = FpV_red( gmul(tabmatinvvite[pkfalse], wpow), R->N ); return gtopoly(wnew,0); | for (j=1; j<ph; j++) w[j] = (long)_powpolmod(pk, modii((GEN)w[j], R->N), R, &sqrmod); w = FpV_red( gmul(tabmatinvvite[pkfalse], w), R->N ); return vec_to_pol(w, 0); | _powpolmodsimple(red_t *R, int pk, GEN jac){ GEN w, wpow, wnew, ma = tabmatvite[pkfalse]; int j, ph = lg(ma); w = mulmat_pol(ma, jac); w = FpV_red(w, R->N); R->red = &_redsimple; wpow = cgetg(ph,t_COL); for (j=1; j<ph; j++) wpow[j] = (long)_powpolmod(pk, (GEN)w[j], R, &sqrmod); wnew = FpV_red( gmul(tabmatinvvite[pkfalse], wpow), R->N ); return gtopoly(wnew,0);} |
if ( fs_to_unmount->mt_fs_root.node_access != fs_root_loc->node_access ) | if ( fs_to_unmount->mt_fs_root.node_access != fs_root_loc->node_access ){ rtems_filesystem_freenode(fs_root_loc); | int file_systems_below_this_mountpoint( const char *path, rtems_filesystem_location_info_t *fs_root_loc, rtems_filesystem_mount_table_entry_t *fs_to_unmount){ Chain_Node *the_node; rtems_filesystem_mount_table_entry_t *the_mount_entry; /* * Is the path even a valid node name in the existing tree? */ if ( rtems_filesystem_evaluate_path( path, 0x0, fs_root_loc, TRUE ) ) return -1; /* * Verify this is the root node for the file system to be unmounted. */ *fs_to_unmount = *fs_root_loc->mt_entry; if ( fs_to_unmount->mt_fs_root.node_access != fs_root_loc->node_access ) set_errno_and_return_minus_one( EACCES ); /* * Search the mount table for any mount entries referencing this * mount entry. */ for ( the_node = rtems_filesystem_mount_table_control.first; !Chain_Is_tail( &rtems_filesystem_mount_table_control, the_node ); the_node = the_node->next ) { the_mount_entry = ( rtems_filesystem_mount_table_entry_t * )the_node; if (the_mount_entry->mt_point_node.mt_entry == fs_root_loc->mt_entry ) { set_errno_and_return_minus_one( EBUSY ); } } return 0;} |
set_errno_and_return_minus_one( EBUSY ); | rtems_filesystem_freenode(fs_root_loc); set_errno_and_return_minus_one( EBUSY ); | int file_systems_below_this_mountpoint( const char *path, rtems_filesystem_location_info_t *fs_root_loc, rtems_filesystem_mount_table_entry_t *fs_to_unmount){ Chain_Node *the_node; rtems_filesystem_mount_table_entry_t *the_mount_entry; /* * Is the path even a valid node name in the existing tree? */ if ( rtems_filesystem_evaluate_path( path, 0x0, fs_root_loc, TRUE ) ) return -1; /* * Verify this is the root node for the file system to be unmounted. */ *fs_to_unmount = *fs_root_loc->mt_entry; if ( fs_to_unmount->mt_fs_root.node_access != fs_root_loc->node_access ) set_errno_and_return_minus_one( EACCES ); /* * Search the mount table for any mount entries referencing this * mount entry. */ for ( the_node = rtems_filesystem_mount_table_control.first; !Chain_Is_tail( &rtems_filesystem_mount_table_control, the_node ); the_node = the_node->next ) { the_mount_entry = ( rtems_filesystem_mount_table_entry_t * )the_node; if (the_mount_entry->mt_point_node.mt_entry == fs_root_loc->mt_entry ) { set_errno_and_return_minus_one( EBUSY ); } } return 0;} |
_Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME ); | _Thread_Set_state( _Thread_Executing, STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL ); | int nanosleep( const struct timespec *rqtp, struct timespec *rmtp){ Watchdog_Interval ticks; if ( rqtp->tv_nsec < 0 || rqtp->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) set_errno_and_return_minus_one( EINVAL ); /* XXX this is interruptible by a posix signal */ ticks = _POSIX_Timespec_to_interval( rqtp ); _Thread_Disable_dispatch(); _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME ); _Watchdog_Initialize( &_Thread_Executing->Timer, _Thread_Delay_ended, /* XXX may need to be POSIX specific */ _Thread_Executing->Object.id, NULL ); _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks ); _Thread_Enable_dispatch(); /* calculate time remaining */ if ( rmtp ) { ticks -= _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time; _POSIX_Interval_to_timespec( ticks, rmtp ); } return 0; /* XXX should account for signal */} |
nfreducemodpr2(GEN nf, GEN x, GEN prinit) | nfreducemodpr2(GEN nf, GEN x, GEN modpr) | nfreducemodpr2(GEN nf, GEN x, GEN prinit){ gpmem_t av = avma; checkprhall(prinit); if (typ(x) != t_COL) x = algtobasis(nf,x); return gerepileupto(av, nfreducemodpr(nf,x,prinit));} |
gpmem_t av = avma; checkprhall(prinit); | gpmem_t av = avma; checkprhall(modpr); | nfreducemodpr2(GEN nf, GEN x, GEN prinit){ gpmem_t av = avma; checkprhall(prinit); if (typ(x) != t_COL) x = algtobasis(nf,x); return gerepileupto(av, nfreducemodpr(nf,x,prinit));} |
return gerepileupto(av, nfreducemodpr(nf,x,prinit)); | return gerepileupto(av, nfreducemodpr(nf,x,modpr)); | nfreducemodpr2(GEN nf, GEN x, GEN prinit){ gpmem_t av = avma; checkprhall(prinit); if (typ(x) != t_COL) x = algtobasis(nf,x); return gerepileupto(av, nfreducemodpr(nf,x,prinit));} |
pari_sp av = avma; long i,lx,tx; GEN p1,z; | pari_sp av; long i, lx, tx; GEN z; | rnfelementdown(GEN rnf,GEN x){ pari_sp av = avma; long i,lx,tx; GEN p1,z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementdown(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: if (gcmp0(x)) return gzero; p1=rnfelementabstorel(rnf,x); if (typ(p1)==t_POLMOD && varn(p1[1])==varn(rnf[1])) p1=(GEN)p1[2]; if (gvar(p1)>varn(rnf[1])) return gerepilecopy(av,p1); if (lgef(p1)==3) return gerepilecopy(av,(GEN)p1[2]); err(talker,"element is not in the base field in rnfelementdown"); default: return gcopy(x); }} |
checkrnf(rnf); tx=typ(x); lx=lg(x); | checkrnf(rnf); tx = typ(x); | rnfelementdown(GEN rnf,GEN x){ pari_sp av = avma; long i,lx,tx; GEN p1,z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementdown(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: if (gcmp0(x)) return gzero; p1=rnfelementabstorel(rnf,x); if (typ(p1)==t_POLMOD && varn(p1[1])==varn(rnf[1])) p1=(GEN)p1[2]; if (gvar(p1)>varn(rnf[1])) return gerepilecopy(av,p1); if (lgef(p1)==3) return gerepilecopy(av,(GEN)p1[2]); err(talker,"element is not in the base field in rnfelementdown"); default: return gcopy(x); }} |
z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementdown(rnf,(GEN)x[i]); | lx = lg(x); z = cgetg(lx,tx); for (i=1; i<lx; i++) z[i] = (long)rnfelementdown(rnf,(GEN)x[i]); | rnfelementdown(GEN rnf,GEN x){ pari_sp av = avma; long i,lx,tx; GEN p1,z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementdown(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: if (gcmp0(x)) return gzero; p1=rnfelementabstorel(rnf,x); if (typ(p1)==t_POLMOD && varn(p1[1])==varn(rnf[1])) p1=(GEN)p1[2]; if (gvar(p1)>varn(rnf[1])) return gerepilecopy(av,p1); if (lgef(p1)==3) return gerepilecopy(av,(GEN)p1[2]); err(talker,"element is not in the base field in rnfelementdown"); default: return gcopy(x); }} |
p1=rnfelementabstorel(rnf,x); if (typ(p1)==t_POLMOD && varn(p1[1])==varn(rnf[1])) p1=(GEN)p1[2]; if (gvar(p1)>varn(rnf[1])) return gerepilecopy(av,p1); if (lgef(p1)==3) return gerepilecopy(av,(GEN)p1[2]); err(talker,"element is not in the base field in rnfelementdown"); | av = avma; z = rnfelementabstorel(rnf,x); if (typ(z)==t_POLMOD && varn(z[1])==varn(rnf[1])) z = (GEN)z[2]; if (gvar(z) <= varn(rnf[1])) { if (lgef(z) > 3) err(talker,"element is not in the base field in rnfelementdown"); z = (GEN)z[2]; } return gerepilecopy(av, z); | rnfelementdown(GEN rnf,GEN x){ pari_sp av = avma; long i,lx,tx; GEN p1,z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementdown(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: if (gcmp0(x)) return gzero; p1=rnfelementabstorel(rnf,x); if (typ(p1)==t_POLMOD && varn(p1[1])==varn(rnf[1])) p1=(GEN)p1[2]; if (gvar(p1)>varn(rnf[1])) return gerepilecopy(av,p1); if (lgef(p1)==3) return gerepilecopy(av,(GEN)p1[2]); err(talker,"element is not in the base field in rnfelementdown"); default: return gcopy(x); }} |
GEN nf,bas,bas1,p1,z; | GEN z, bas = (GEN)rnf[7], nf = (GEN)rnf[10]; | rnfprincipaltohermite(GEN rnf,GEN x){ pari_sp av = avma; GEN nf,bas,bas1,p1,z; x = rnfbasistoalg(rnf,x); nf = (GEN)rnf[10]; bas = (GEN)rnf[7]; bas1 = (GEN)bas[1]; p1 = rnfalgtobasis(rnf, gmul(x,gmodulcp(bas1,(GEN)rnf[1]))); settyp(p1,t_MAT); z = cgetg(3,t_VEC); z[1] = (long)p1; z[2] = bas[2]; return gerepileupto(av, nfhermite(nf,z));} |
x = rnfbasistoalg(rnf,x); nf = (GEN)rnf[10]; bas = (GEN)rnf[7]; bas1 = (GEN)bas[1]; p1 = rnfalgtobasis(rnf, gmul(x,gmodulcp(bas1,(GEN)rnf[1]))); settyp(p1,t_MAT); | x = rnfbasistoalg(rnf,x); x = rnfalgtobasis(rnf, gmul(x, gmodulcp((GEN)bas[1], (GEN)rnf[1]))); | rnfprincipaltohermite(GEN rnf,GEN x){ pari_sp av = avma; GEN nf,bas,bas1,p1,z; x = rnfbasistoalg(rnf,x); nf = (GEN)rnf[10]; bas = (GEN)rnf[7]; bas1 = (GEN)bas[1]; p1 = rnfalgtobasis(rnf, gmul(x,gmodulcp(bas1,(GEN)rnf[1]))); settyp(p1,t_MAT); z = cgetg(3,t_VEC); z[1] = (long)p1; z[2] = bas[2]; return gerepileupto(av, nfhermite(nf,z));} |
z[1] = (long)p1; | z[1] = (long)x; settyp(x, t_MAT); | rnfprincipaltohermite(GEN rnf,GEN x){ pari_sp av = avma; GEN nf,bas,bas1,p1,z; x = rnfbasistoalg(rnf,x); nf = (GEN)rnf[10]; bas = (GEN)rnf[7]; bas1 = (GEN)bas[1]; p1 = rnfalgtobasis(rnf, gmul(x,gmodulcp(bas1,(GEN)rnf[1]))); settyp(p1,t_MAT); z = cgetg(3,t_VEC); z[1] = (long)p1; z[2] = bas[2]; return gerepileupto(av, nfhermite(nf,z));} |
RES[5] = (long)rnfmakematrices(RES); | rnfinitalg(GEN nf,GEN pol,long prec){ gpmem_t av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[5] = (long)rnfmakematrices(RES); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
|
RES[5] = (long)rnfmakematrices(RES); | rnfinitalg(GEN nf,GEN pol,long prec){ gpmem_t av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[5] = (long)rnfmakematrices(RES); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
|
checkrnf(rnf); tx=typ(x); lx=lg(x); | checkrnf(rnf); tx = typ(x); | rnfelementup(GEN rnf,GEN x){ long i,lx,tx; GEN z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementup(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: return poleval(x,gmael(rnf,11,2)); default: return gcopy(x); }} |
z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementup(rnf,(GEN)x[i]); | lx = lg(x); z = cgetg(lx,tx); for (i=1; i<lx; i++) z[i] = (long)rnfelementup(rnf,(GEN)x[i]); | rnfelementup(GEN rnf,GEN x){ long i,lx,tx; GEN z; checkrnf(rnf); tx=typ(x); lx=lg(x); switch(tx) { case t_VEC: case t_COL: case t_MAT: z=cgetg(lx,tx); for (i=1; i<lx; i++) z[i]=(long)rnfelementup(rnf,(GEN)x[i]); return z; case t_POLMOD: x=(GEN)x[2]; /* fall through */ case t_POL: return poleval(x,gmael(rnf,11,2)); default: return gcopy(x); }} |
strncpy( node->name, name, NAME_MAX ); | strncpy( node->name, name, IMFS_NAME_MAX ); | IMFS_jnode_t *IMFS_create_node( rtems_filesystem_location_info_t *parent_loc, IMFS_jnode_types_t type, char *name, mode_t mode, IMFS_types_union *info){ IMFS_jnode_t *node; struct timeval tv; IMFS_jnode_t *parent = NULL; IMFS_fs_info_t *fs_info; char *sym_name; if ( parent_loc != NULL ) parent = parent_loc->node_access; /* * Allocate an IMFS jnode */ node = calloc( 1, sizeof( IMFS_jnode_t ) ); if ( !node ) return NULL; /* * Fill in the basic information */ node->st_nlink = 1; node->type = type; strncpy( node->name, name, NAME_MAX ); /* * Fill in the mode and permission information for the jnode structure. */ node->st_mode = mode & ~rtems_filesystem_umask; #if defined(RTEMS_POSIX_API) node->st_uid = geteuid(); node->st_gid = getegid();#else node->st_uid = 0; node->st_gid = 0;#endif /* * Now set all the times. */ gettimeofday( &tv, 0 ); node->st_atime = (time_t) tv.tv_sec; node->st_mtime = (time_t) tv.tv_sec; node->st_ctime = (time_t) tv.tv_sec; /* * Set the type specific information */ switch (type) { case IMFS_DIRECTORY: Chain_Initialize_empty(&node->info.directory.Entries); break; case IMFS_HARD_LINK: node->info.hard_link.link_node = info->hard_link.link_node; break; case IMFS_SYM_LINK: sym_name = calloc( 1, strlen( info->sym_link.name ) + 1 ); strcpy( sym_name, info->sym_link.name ); node->info.sym_link.name = sym_name; break; case IMFS_DEVICE: node->info.device.major = info->device.major; node->info.device.minor = info->device.minor; break; case IMFS_MEMORY_FILE: node->info.file.size = 0; node->info.file.indirect = 0; node->info.file.doubly_indirect = 0; node->info.file.triply_indirect = 0; break; default: assert(0); break; } /* * If this node has a parent, then put it in that directory list. */ if ( parent ) { Chain_Append( &parent->info.directory.Entries, &node->Node ); node->Parent = parent; fs_info = parent_loc->mt_entry->fs_info; node->st_ino = ++fs_info->ino_count; } return node;} |
long rcolcnt[MAX_COLORS][ROt_MAX]; long rcnt[ROt_MAX+1]; | col_counter rcolcnt; | class Plotter: public QWidget {#ifdef __FANCY_WIN__ Q_OBJECTsignals: void clicked();protected: void mouseReleaseEvent( QMouseEvent*);#endifpublic: Plotter( long *w, long *x, long *y, long lw, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); ~Plotter(); void save( const QString& s = *plotFile + ".xpm",//QString("pariplot.xpm"), const QString& f = QString( "XPM"));protected: void paintEvent( QPaintEvent *); void resizeEvent ( QResizeEvent *);#ifndef __FANCY_WIN__ void keyPressEvent( QKeyEvent *);#endifprivate: void alloc(); void plot();private: long *w; // map into rectgraph indexes long *x; // x, y: array of x,y-coorinates of the long *y; // top left corners of the rectwindows long lw; // lw: number of rectwindows long rcolcnt[MAX_COLORS][ROt_MAX]; long rcnt[ROt_MAX+1]; QPointArray _points[MAX_COLORS]; QPointArray _seg[MAX_COLORS]; QPointArray *_lines[MAX_COLORS]; QRect *_rec[MAX_COLORS]; QPointArray _textPos[MAX_COLORS]; QString *_texts[MAX_COLORS]; QColor color[MAX_COLORS]; QFont font; static QString *plotFile;// public:// static void setPlotFile( const char *);}; |
int i; | int unitNumber; char *unitName; | rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config){ struct scc_softc *sc; struct ifnet *ifp; int mtu; int i; /* * Find a free driver */ for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); return 0; } /* * Process options */ if (config->hardware_address) { memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { /* * The first 4 bytes of the bootstrap prom * contain the value loaded into the stack * pointer as part of the CPU32's hardware * reset exception handler. The following * 4 bytes contain the value loaded into the * program counter. The boards' Ethernet * address is stored in the six bytes * immediately preceding this initial * program counter value. * * See start360/start360.s. */ extern void *_RomBase; /* From linkcmds */ const unsigned long *ExceptionVectors; const unsigned char *entryPoint; /* * Sanity check -- assume entry point must be * within 1 MByte of beginning of boot ROM. */ ExceptionVectors = (const unsigned long *)&_RomBase; entryPoint = (const unsigned char *)ExceptionVectors[1]; if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors) >= (1 * 1024 * 1024)) { printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n"); sc->arpcom.ac_enaddr[0] = 0x08; sc->arpcom.ac_enaddr[1] = 0xF3; sc->arpcom.ac_enaddr[2] = 0x3E; sc->arpcom.ac_enaddr[3] = 0xC2; sc->arpcom.ac_enaddr[4] = 0x7E; sc->arpcom.ac_enaddr[5] = 0x38; } else { memcpy (sc->arpcom.ac_enaddr, entryPoint - ETHER_ADDR_LEN, ETHER_ADDR_LEN); } } if (config->mtu) mtu = config->mtu; else mtu = ETHERMTU; if (config->rbuf_count) sc->rxBdCount = config->rbuf_count; else sc->rxBdCount = RX_BUF_COUNT; if (config->xbuf_count) sc->txBdCount = config->xbuf_count; else sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF; sc->acceptBroadcast = !config->ignore_broadcast; /* * Set up network interface values */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "scc"; ifp->if_mtu = mtu; ifp->if_init = scc_init; ifp->if_ioctl = scc_ioctl; ifp->if_start = scc_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Attach the interface */ if_attach (ifp); ether_ifattach (ifp); return 1;}; |
* Find a free driver | * Parse driver name | rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config){ struct scc_softc *sc; struct ifnet *ifp; int mtu; int i; /* * Find a free driver */ for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); return 0; } /* * Process options */ if (config->hardware_address) { memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { /* * The first 4 bytes of the bootstrap prom * contain the value loaded into the stack * pointer as part of the CPU32's hardware * reset exception handler. The following * 4 bytes contain the value loaded into the * program counter. The boards' Ethernet * address is stored in the six bytes * immediately preceding this initial * program counter value. * * See start360/start360.s. */ extern void *_RomBase; /* From linkcmds */ const unsigned long *ExceptionVectors; const unsigned char *entryPoint; /* * Sanity check -- assume entry point must be * within 1 MByte of beginning of boot ROM. */ ExceptionVectors = (const unsigned long *)&_RomBase; entryPoint = (const unsigned char *)ExceptionVectors[1]; if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors) >= (1 * 1024 * 1024)) { printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n"); sc->arpcom.ac_enaddr[0] = 0x08; sc->arpcom.ac_enaddr[1] = 0xF3; sc->arpcom.ac_enaddr[2] = 0x3E; sc->arpcom.ac_enaddr[3] = 0xC2; sc->arpcom.ac_enaddr[4] = 0x7E; sc->arpcom.ac_enaddr[5] = 0x38; } else { memcpy (sc->arpcom.ac_enaddr, entryPoint - ETHER_ADDR_LEN, ETHER_ADDR_LEN); } } if (config->mtu) mtu = config->mtu; else mtu = ETHERMTU; if (config->rbuf_count) sc->rxBdCount = config->rbuf_count; else sc->rxBdCount = RX_BUF_COUNT; if (config->xbuf_count) sc->txBdCount = config->xbuf_count; else sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF; sc->acceptBroadcast = !config->ignore_broadcast; /* * Set up network interface values */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "scc"; ifp->if_mtu = mtu; ifp->if_init = scc_init; ifp->if_ioctl = scc_ioctl; ifp->if_start = scc_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Attach the interface */ if_attach (ifp); ether_ifattach (ifp); return 1;}; |
for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; | if ((unitNumber = rtems_bsdnet_parse_driver_name (config, &unitName)) < 0) return 0; if ((unitNumber <= 0) || (unitNumber > NSCCDRIVER)) { printf ("Bad SCC unit number.\n"); return 0; | rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config){ struct scc_softc *sc; struct ifnet *ifp; int mtu; int i; /* * Find a free driver */ for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); return 0; } /* * Process options */ if (config->hardware_address) { memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { /* * The first 4 bytes of the bootstrap prom * contain the value loaded into the stack * pointer as part of the CPU32's hardware * reset exception handler. The following * 4 bytes contain the value loaded into the * program counter. The boards' Ethernet * address is stored in the six bytes * immediately preceding this initial * program counter value. * * See start360/start360.s. */ extern void *_RomBase; /* From linkcmds */ const unsigned long *ExceptionVectors; const unsigned char *entryPoint; /* * Sanity check -- assume entry point must be * within 1 MByte of beginning of boot ROM. */ ExceptionVectors = (const unsigned long *)&_RomBase; entryPoint = (const unsigned char *)ExceptionVectors[1]; if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors) >= (1 * 1024 * 1024)) { printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n"); sc->arpcom.ac_enaddr[0] = 0x08; sc->arpcom.ac_enaddr[1] = 0xF3; sc->arpcom.ac_enaddr[2] = 0x3E; sc->arpcom.ac_enaddr[3] = 0xC2; sc->arpcom.ac_enaddr[4] = 0x7E; sc->arpcom.ac_enaddr[5] = 0x38; } else { memcpy (sc->arpcom.ac_enaddr, entryPoint - ETHER_ADDR_LEN, ETHER_ADDR_LEN); } } if (config->mtu) mtu = config->mtu; else mtu = ETHERMTU; if (config->rbuf_count) sc->rxBdCount = config->rbuf_count; else sc->rxBdCount = RX_BUF_COUNT; if (config->xbuf_count) sc->txBdCount = config->xbuf_count; else sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF; sc->acceptBroadcast = !config->ignore_broadcast; /* * Set up network interface values */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "scc"; ifp->if_mtu = mtu; ifp->if_init = scc_init; ifp->if_ioctl = scc_ioctl; ifp->if_start = scc_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Attach the interface */ if_attach (ifp); ether_ifattach (ifp); return 1;}; |
if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); | sc = &scc_softc[unitNumber - 1]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc != NULL) { printf ("Driver already in use.\n"); | rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config){ struct scc_softc *sc; struct ifnet *ifp; int mtu; int i; /* * Find a free driver */ for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); return 0; } /* * Process options */ if (config->hardware_address) { memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { /* * The first 4 bytes of the bootstrap prom * contain the value loaded into the stack * pointer as part of the CPU32's hardware * reset exception handler. The following * 4 bytes contain the value loaded into the * program counter. The boards' Ethernet * address is stored in the six bytes * immediately preceding this initial * program counter value. * * See start360/start360.s. */ extern void *_RomBase; /* From linkcmds */ const unsigned long *ExceptionVectors; const unsigned char *entryPoint; /* * Sanity check -- assume entry point must be * within 1 MByte of beginning of boot ROM. */ ExceptionVectors = (const unsigned long *)&_RomBase; entryPoint = (const unsigned char *)ExceptionVectors[1]; if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors) >= (1 * 1024 * 1024)) { printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n"); sc->arpcom.ac_enaddr[0] = 0x08; sc->arpcom.ac_enaddr[1] = 0xF3; sc->arpcom.ac_enaddr[2] = 0x3E; sc->arpcom.ac_enaddr[3] = 0xC2; sc->arpcom.ac_enaddr[4] = 0x7E; sc->arpcom.ac_enaddr[5] = 0x38; } else { memcpy (sc->arpcom.ac_enaddr, entryPoint - ETHER_ADDR_LEN, ETHER_ADDR_LEN); } } if (config->mtu) mtu = config->mtu; else mtu = ETHERMTU; if (config->rbuf_count) sc->rxBdCount = config->rbuf_count; else sc->rxBdCount = RX_BUF_COUNT; if (config->xbuf_count) sc->txBdCount = config->xbuf_count; else sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF; sc->acceptBroadcast = !config->ignore_broadcast; /* * Set up network interface values */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "scc"; ifp->if_mtu = mtu; ifp->if_init = scc_init; ifp->if_ioctl = scc_ioctl; ifp->if_start = scc_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Attach the interface */ if_attach (ifp); ether_ifattach (ifp); return 1;}; |
ifp->if_unit = i + 1; ifp->if_name = "scc"; | ifp->if_unit = unitNumber; ifp->if_name = unitName; | rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config){ struct scc_softc *sc; struct ifnet *ifp; int mtu; int i; /* * Find a free driver */ for (i = 0 ; i < NSCCDRIVER ; i++) { sc = &scc_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (i >= NSCCDRIVER) { printf ("Too many SCC drivers.\n"); return 0; } /* * Process options */ if (config->hardware_address) { memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); } else { /* * The first 4 bytes of the bootstrap prom * contain the value loaded into the stack * pointer as part of the CPU32's hardware * reset exception handler. The following * 4 bytes contain the value loaded into the * program counter. The boards' Ethernet * address is stored in the six bytes * immediately preceding this initial * program counter value. * * See start360/start360.s. */ extern void *_RomBase; /* From linkcmds */ const unsigned long *ExceptionVectors; const unsigned char *entryPoint; /* * Sanity check -- assume entry point must be * within 1 MByte of beginning of boot ROM. */ ExceptionVectors = (const unsigned long *)&_RomBase; entryPoint = (const unsigned char *)ExceptionVectors[1]; if (((unsigned long)entryPoint - (unsigned long)ExceptionVectors) >= (1 * 1024 * 1024)) { printf ("Warning -- Ethernet address can not be found in bootstrap PROM.\n"); sc->arpcom.ac_enaddr[0] = 0x08; sc->arpcom.ac_enaddr[1] = 0xF3; sc->arpcom.ac_enaddr[2] = 0x3E; sc->arpcom.ac_enaddr[3] = 0xC2; sc->arpcom.ac_enaddr[4] = 0x7E; sc->arpcom.ac_enaddr[5] = 0x38; } else { memcpy (sc->arpcom.ac_enaddr, entryPoint - ETHER_ADDR_LEN, ETHER_ADDR_LEN); } } if (config->mtu) mtu = config->mtu; else mtu = ETHERMTU; if (config->rbuf_count) sc->rxBdCount = config->rbuf_count; else sc->rxBdCount = RX_BUF_COUNT; if (config->xbuf_count) sc->txBdCount = config->xbuf_count; else sc->txBdCount = TX_BUF_COUNT * TX_BD_PER_BUF; sc->acceptBroadcast = !config->ignore_broadcast; /* * Set up network interface values */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "scc"; ifp->if_mtu = mtu; ifp->if_init = scc_init; ifp->if_ioctl = scc_ioctl; ifp->if_start = scc_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Attach the interface */ if_attach (ifp); ether_ifattach (ifp); return 1;}; |
Objects_Name name, | rtems_name name, | rtems_status_code rtems_semaphore_create( Objects_Name name, unsigned32 count, rtems_attribute attribute_set, Objects_Id *id){ return( RTEMS_NOT_CONFIGURED );} |
Objects_Name name, | rtems_name name, | rtems_status_code rtems_semaphore_ident( Objects_Name name, unsigned32 node, Objects_Id *id){ return( RTEMS_NOT_CONFIGURED );} |
case IMFS_LINEAR_FILE: | int IMFS_stat( rtems_filesystem_location_info_t *loc, struct stat *buf){ IMFS_jnode_t *the_jnode; IMFS_device_t *io; the_jnode = loc->node_access; switch ( the_jnode->type ) { case IMFS_DEVICE: io = &the_jnode->info.device; buf->st_dev = rtems_filesystem_make_dev_t( io->major, io->minor ); break; case IMFS_MEMORY_FILE: buf->st_size = the_jnode->info.file.size; break; case IMFS_SYM_LINK: buf->st_size = 0; break; default: set_errno_and_return_minus_one( ENOTSUP ); break; } buf->st_mode = the_jnode->st_mode; buf->st_nlink = the_jnode->st_nlink; buf->st_ino = the_jnode->st_ino; buf->st_uid = the_jnode->st_uid; buf->st_gid = the_jnode->st_gid; buf->st_atime = the_jnode->stat_atime; buf->st_mtime = the_jnode->stat_mtime; buf->st_ctime = the_jnode->stat_ctime; return 0;} |
|
for(i=1, nb=1; i<n; i++, nb*=2) | for(i=1, nb=1; i<n; i++, nb*=4) | fixedfieldsympol(GEN O, GEN mod, GEN l, GEN p, long v){ pari_sp ltop=avma; GEN V=NULL; long n=lg(O[1])*2; GEN LN=cgetg(n,t_MAT); GEN Ll=cgetg(n,t_MAT); long i,nb,ok=0; for(i=1, nb=1; i<n; i++, nb*=2) { LN[i]=(long)sympol_eval_newtonsum(i,O,mod); Ll[i]=(long)FpV_red((GEN)LN[i],l); if (DEBUGLEVEL>=6) fprintferr("FixedField: LN[%d]=%Z \n",i,Ll[i]); if (i==n) nb*=4; ok = (ok || fixedfieldtests(Ll,i)); if (ok) if ((V=fixedfieldsurmer(O,mod,l,p,v,LN,i,nb))) { if (DEBUGLEVEL>=4) pariputsf("FixedField: Sym: %Z\n",(GEN)V[1]); return gerepilecopy(ltop,V); } } err(talker,"p too small in fixedfieldsympol"); return NULL;} |
if (i==n) nb*=4; | fixedfieldsympol(GEN O, GEN mod, GEN l, GEN p, long v){ pari_sp ltop=avma; GEN V=NULL; long n=lg(O[1])*2; GEN LN=cgetg(n,t_MAT); GEN Ll=cgetg(n,t_MAT); long i,nb,ok=0; for(i=1, nb=1; i<n; i++, nb*=2) { LN[i]=(long)sympol_eval_newtonsum(i,O,mod); Ll[i]=(long)FpV_red((GEN)LN[i],l); if (DEBUGLEVEL>=6) fprintferr("FixedField: LN[%d]=%Z \n",i,Ll[i]); if (i==n) nb*=4; ok = (ok || fixedfieldtests(Ll,i)); if (ok) if ((V=fixedfieldsurmer(O,mod,l,p,v,LN,i,nb))) { if (DEBUGLEVEL>=4) pariputsf("FixedField: Sym: %Z\n",(GEN)V[1]); return gerepilecopy(ltop,V); } } err(talker,"p too small in fixedfieldsympol"); return NULL;} |
|
prep=vandermondeinverseprep(L,T); | prep=vandermondeinverseprep(T,L); | vandermondeinverse(GEN L, GEN T, GEN den, GEN prep){ ulong ltop = avma, lbot; int i, j, n = lg(L); long x = varn(T); GEN M, P; if (!prep) prep=vandermondeinverseprep(L,T); M = cgetg(n, t_MAT); for (i = 1; i < n; i++) { M[i] = lgetg(n, t_COL); P = gdiv(gdeuc(T, gsub(polx[x], (GEN) L[i])), (GEN) prep[i]); for (j = 1; j < n; j++) ((GEN *) M)[i][j] = P[1 + j]; } lbot = avma; M = gmul(den, M); return gerepile(ltop, lbot, M);} |
if (PG == gzero) return NULL; | galoisgenfixedfield(GEN Tp, GEN Pmod, GEN V, GEN ip, struct galois_borne *gb, GEN Pg){ ulong ltop=avma; GEN P, PL, Pden, PM, Pp, Pladicabs; GEN tau, PG; long g,gp; long x=varn(Tp); P=(GEN)V[2]; PL=(GEN)V[1]; gp=lg(Pmod)-1; Pp = FpX_red(P,ip); if (degpol(P)==2) { PG=cgetg(3,t_VEC); PG[1]=lgetg(2,t_VEC); PG[2]=lgetg(2,t_VECSMALL); mael(PG,1,1)=lgetg(3,t_VECSMALL); mael(PG,2,1)=2; mael3(PG,1,1,1)=2; mael3(PG,1,1,2)=1; tau=deg1pol(stoi(-1),negi((GEN)P[3]),x); tau = lift(gmul(tau,gmodulcp(gun,ip))); tau = FpX_FpXQ_compo((GEN) Pmod[gp], tau,Pp,ip); tau = FpX_gcd(Pp, tau,ip); tau = FpX_Fp_mul(tau,mpinvmod((GEN) tau[lgef(tau) - 1],ip),ip); for (g = 1; g <= gp; g++) if (gegal(tau, (GEN) Pmod[g])) break; if (g == lg(Pmod)) return NULL; Pg[1]=g; } else { struct galois_analysis Pga; struct galois_borne Pgb; long j; galoisanalysis(P, &Pga, 0, 0); if (Pga.deg == 0) return NULL; /* Avoid computing the discriminant */ Pgb.l = gb->l; Pden = galoisborne(P, NULL, &Pgb, Pga.ppp); Pladicabs=Pgb.ladicabs; if (Pgb.valabs > gb->valabs) { if (DEBUGLEVEL>=4) fprintferr("GaloisConj:increase prec of p-adic roots of %ld.\n" ,Pgb.valabs-gb->valabs); PL = rootpadicliftroots(P,PL,gb->l,Pgb.valabs); } PM = vandermondeinversemod(PL, P, Pden, Pgb.ladicabs); PG = galoisgen(P, PL, PM, Pden, &Pgb, &Pga); for (j = 1; j < lg(PG[1]); j++) { ulong btop=avma; tau = permtopol(gmael(PG,1,j), PL, PM, Pden, Pladicabs, x); tau = lift(gmul(tau,gmodulcp(gun,ip))); tau = FpX_FpXQ_compo((GEN) Pmod[gp], tau,Pp,ip); tau = FpX_gcd(Pp, tau,ip); tau = FpX_Fp_mul(tau,mpinvmod((GEN) tau[lgef(tau) - 1],ip),ip); for (g = 1; g < lg(Pmod); g++) if (gegal(tau, (GEN) Pmod[g])) break; if (g == lg(Pmod)) return NULL; avma=btop; Pg[j]=g; } } return gerepilecopy(ltop,PG);} |
|
{ setlg(p1,k); p1 = gerepile(av,av1,gcopy(p1)); } | { setlg(p1,k); p1 = gerepilecopy(av,p1); } | FBgen(GEN nf,long n2,long n){ byteptr delta=diffptr; long KC2,i,j,k,p,lon,ip,nor, N = degpol(nf[1]); GEN p2,p1,NormP,lfun; long prim[] = { evaltyp(t_INT)|m_evallg(3), evalsigne(1)|evallgefint(3),0 }; numFB = cgetg(n2+1,t_VECSMALL); FB = cgetg(n2+1,t_VECSMALL); numideal = cgetg(n2+1,t_VECSMALL); idealbase= (GEN*)cgetg(n2+1,t_VEC); lfun=realun(DEFAULTPREC); p=*delta++; i=0; ip=0; KC=0; while (p<=n2) { long av = avma, av1; if (DEBUGLEVEL>=2) { fprintferr(" %ld",p); flusherr(); } prim[2] = p; p1 = primedec(nf,prim); lon=lg(p1); av1 = avma; divrsz(mulsr(p-1,lfun),p,lfun); if (itos(gmael(p1,1,4)) == N) /* p inert */ { NormP = gpowgs(prim,N); if (!is_bigint(NormP) && (nor=NormP[2]) <= n2) divrsz(mulsr(nor,lfun),nor-1, lfun); avma = av1; } else { numideal[p]=ip; i++; numFB[p]=i; FB[i]=p; for (k=1; k<lon; k++,ip++) { NormP = powgi(prim,gmael(p1,k,4)); if (is_bigint(NormP) || (nor=NormP[2]) > n2) break; divrsz(mulsr(nor,lfun),nor-1, lfun); } /* keep all ideals with Norm <= n2 */ avma = av1; if (k == lon) setisclone(p1); /* flag it: all prime divisors in FB */ else { setlg(p1,k); p1 = gerepile(av,av1,gcopy(p1)); } idealbase[i] = p1; } if (!*delta) err(primer1); p += *delta++; if (KC == 0 && p>n) { KCZ=i; KC=ip; } } if (!KC) return NULL; KCZ2=i; KC2=ip; MAXRELSUP = min(50,4*KC); setlg(FB,KCZ2); setlg(numFB,KCZ2); setlg(numideal,KCZ2); setlg(idealbase,KCZ2); vectbase=cgetg(KC+1,t_COL); for (i=1; i<=KCZ; i++) { p1 = idealbase[i]; k=lg(p1); p2 = vectbase + numideal[FB[i]]; for (j=1; j<k; j++) p2[j]=p1[j]; } if (DEBUGLEVEL) { if (DEBUGLEVEL>1) fprintferr("\n"); if (DEBUGLEVEL>6) { fprintferr("########## FACTORBASE ##########\n\n"); fprintferr("KC2=%ld, KC=%ld, KCZ=%ld, KCZ2=%ld, MAXRELSUP=%ld\n", KC2, KC, KCZ, KCZ2, MAXRELSUP); for (i=1; i<=KCZ; i++) fprintferr("++ idealbase[%ld] = %Z",i,idealbase[i]); } msgtimer("factor base"); } return lfun;} |
case IMFS_LINEAR_FILE: loc->handlers = fs_info->linearfile_handlers; break; | int IMFS_Set_handlers( rtems_filesystem_location_info_t *loc){ IMFS_jnode_t *node = loc->node_access; IMFS_fs_info_t *fs_info; fs_info = loc->mt_entry->fs_info; switch( node->type ) { case IMFS_DIRECTORY: loc->handlers = fs_info->directory_handlers; break; case IMFS_DEVICE: loc->handlers = &IMFS_device_handlers; break; case IMFS_SYM_LINK: case IMFS_HARD_LINK: loc->handlers = &IMFS_link_handlers; break; case IMFS_MEMORY_FILE: loc->handlers = fs_info->memfile_handlers; break; } return 0;} |
|
GEN nf,mat,mat1,qgen,decqq,newcol,Qh,Q,g,ord; | GEN nf,mat,mat1,qgen,decqq,newcol,Q,g,ord,modpr; | primecertify(GEN bnf,GEN beta,long pp,GEN big){ long i,j,qq,nbcol,lb,nbqq,ra,N; GEN nf,mat,mat1,qgen,decqq,newcol,Qh,Q,g,ord; ord = NULL; /* gcc -Wall */ nbcol = 0; nf = (GEN)bnf[7]; N = degpol(nf[1]); lb = lg(beta)-1; mat = cgetg(1,t_MAT); qq = 1; for(;;) { qq += 2*pp; qgen = stoi(qq); if (smodis(big,qq)==0 || !isprime(qgen)) continue; decqq = primedec(bnf,qgen); nbqq = lg(decqq)-1; g = NULL; for (i=1; i<=nbqq; i++) { Q = (GEN)decqq[i]; if (!gcmp1((GEN)Q[4])) break; /* Q has degree 1 */ if (!g) { g = lift_intern(gener(qgen)); /* primitive root */ ord = decomp(stoi(qq-1)); } Qh = prime_to_ideal(nf,Q); newcol = cgetg(lb+1,t_COL); for (j=1; j<=lb; j++) { GEN t = to_Fp_simple(nf, (GEN)beta[j], Qh); newcol[j] = (long)Fp_PHlog(t,g,qgen,ord); } if (DEBUGLEVEL>3) { if (i==1) fprintferr(" generator of (Zk/Q)^*: %Z\n", g); fprintferr(" prime ideal Q: %Z\n",Q); fprintferr(" column #%ld of the matrix log(b_j/Q): %Z\n", nbcol, newcol); } mat1 = concatsp(mat,newcol); ra = rank(mat1); if (ra==nbcol) continue; if (DEBUGLEVEL>2) fprintferr(" new rank: %ld\n",ra); if (++nbcol == lb) return; mat = mat1; } }} |
Qh = prime_to_ideal(nf,Q); | modpr = zkmodprinit(nf, Q); | primecertify(GEN bnf,GEN beta,long pp,GEN big){ long i,j,qq,nbcol,lb,nbqq,ra,N; GEN nf,mat,mat1,qgen,decqq,newcol,Qh,Q,g,ord; ord = NULL; /* gcc -Wall */ nbcol = 0; nf = (GEN)bnf[7]; N = degpol(nf[1]); lb = lg(beta)-1; mat = cgetg(1,t_MAT); qq = 1; for(;;) { qq += 2*pp; qgen = stoi(qq); if (smodis(big,qq)==0 || !isprime(qgen)) continue; decqq = primedec(bnf,qgen); nbqq = lg(decqq)-1; g = NULL; for (i=1; i<=nbqq; i++) { Q = (GEN)decqq[i]; if (!gcmp1((GEN)Q[4])) break; /* Q has degree 1 */ if (!g) { g = lift_intern(gener(qgen)); /* primitive root */ ord = decomp(stoi(qq-1)); } Qh = prime_to_ideal(nf,Q); newcol = cgetg(lb+1,t_COL); for (j=1; j<=lb; j++) { GEN t = to_Fp_simple(nf, (GEN)beta[j], Qh); newcol[j] = (long)Fp_PHlog(t,g,qgen,ord); } if (DEBUGLEVEL>3) { if (i==1) fprintferr(" generator of (Zk/Q)^*: %Z\n", g); fprintferr(" prime ideal Q: %Z\n",Q); fprintferr(" column #%ld of the matrix log(b_j/Q): %Z\n", nbcol, newcol); } mat1 = concatsp(mat,newcol); ra = rank(mat1); if (ra==nbcol) continue; if (DEBUGLEVEL>2) fprintferr(" new rank: %ld\n",ra); if (++nbcol == lb) return; mat = mat1; } }} |
GEN t = to_Fp_simple(nf, (GEN)beta[j], Qh); | GEN t = to_Fp_simple(nf, (GEN)beta[j], modpr); | primecertify(GEN bnf,GEN beta,long pp,GEN big){ long i,j,qq,nbcol,lb,nbqq,ra,N; GEN nf,mat,mat1,qgen,decqq,newcol,Qh,Q,g,ord; ord = NULL; /* gcc -Wall */ nbcol = 0; nf = (GEN)bnf[7]; N = degpol(nf[1]); lb = lg(beta)-1; mat = cgetg(1,t_MAT); qq = 1; for(;;) { qq += 2*pp; qgen = stoi(qq); if (smodis(big,qq)==0 || !isprime(qgen)) continue; decqq = primedec(bnf,qgen); nbqq = lg(decqq)-1; g = NULL; for (i=1; i<=nbqq; i++) { Q = (GEN)decqq[i]; if (!gcmp1((GEN)Q[4])) break; /* Q has degree 1 */ if (!g) { g = lift_intern(gener(qgen)); /* primitive root */ ord = decomp(stoi(qq-1)); } Qh = prime_to_ideal(nf,Q); newcol = cgetg(lb+1,t_COL); for (j=1; j<=lb; j++) { GEN t = to_Fp_simple(nf, (GEN)beta[j], Qh); newcol[j] = (long)Fp_PHlog(t,g,qgen,ord); } if (DEBUGLEVEL>3) { if (i==1) fprintferr(" generator of (Zk/Q)^*: %Z\n", g); fprintferr(" prime ideal Q: %Z\n",Q); fprintferr(" column #%ld of the matrix log(b_j/Q): %Z\n", nbcol, newcol); } mat1 = concatsp(mat,newcol); ra = rank(mat1); if (ra==nbcol) continue; if (DEBUGLEVEL>2) fprintferr(" new rank: %ld\n",ra); if (++nbcol == lb) return; mat = mat1; } }} |
long lgsunitrelnf,i,lbot, ltop = avma; | long lgsunitrelnf,i; ulong ltop = avma; | rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i,lbot, ltop = avma; GEN relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (long)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag>1) { for (i=2; i<=flag; i++) if (isprime(stoi(i)) && signe(resis(prod,i))) { prod=mulis(prod,i); S1=concatsp(S1,primedec(bnf,stoi(i))); S2=concatsp(S2,primedec(relnf,stoi(i))); } } else if (flag<0) vecconcat(bnf,relnf,(GEN)factor(stoi(-flag))[1],&prod,&S1,&S2); if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN) idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; lbot=avma; return gerepile(ltop,lbot,gcopy(res));} |
lbot=avma; return gerepile(ltop,lbot,gcopy(res)); | return gerepilecopy(ltop,res); | rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i,lbot, ltop = avma; GEN relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); if (typ(x)!=t_POL) x = basistoalg(bnf,x); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degpol(ext[1])&1))) { avma = (long)res; res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degpol(ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag>1) { for (i=2; i<=flag; i++) if (isprime(stoi(i)) && signe(resis(prod,i))) { prod=mulis(prod,i); S1=concatsp(S1,primedec(bnf,stoi(i))); S2=concatsp(S2,primedec(relnf,stoi(i))); } } else if (flag<0) vecconcat(bnf,relnf,(GEN)factor(stoi(-flag))[1],&prod,&S1,&S2); if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN) idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(precer,"bnfisnorm, please increase precision and try again"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(aux,sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); x = gdiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); if (typ(x) == t_POLMOD && (typ(x[2]) != t_POL || lgef(x[2]) == 3)) { x = (GEN)x[2]; /* rational number */ if (typ(x) == t_POL) x = (GEN)x[2]; } res[1]=(long)aux; res[2]=(long)x; lbot=avma; return gerepile(ltop,lbot,gcopy(res));} |
long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; | long vpol; GEN rnf, delta, bas, f2, M, p1, z; | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
nf=checknf(nf); n=degpol(pol); vpol=varn(pol); | nf=checknf(nf); vpol=varn(pol); | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
vnf = varn(nf[1]); | if (vpol >= varn(nf[1])) err(talker,"main variable must be of higher priority in rnfinitalg"); rnf = cgetg(14, t_VEC); rnf[1] = (long)pol; rnf[6] = (long)rnf_roots(nf, lift(pol), prec, (GEN*)rnf+2); | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } | z = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = z[3]; delta[2] = z[4]; rnf[3] = (long)delta; p1 = matbasistoalg(nf,(GEN)z[1]); bas = cgetg(3,t_VEC); bas[1] = (long)lift_if_rational( mat_to_vecpol(p1,vpol) ); bas[2] = (long)z[2]; rnf[7] = (long)bas; rnf[8] = (long)lift_if_rational( invmat(p1) ); | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); | f2 = idealdiv(nf, discsr(pol), (GEN)z[3]); rnf[4] = (long)idealsqrtn(nf, f2, gdeux, 1); rnf[9] = lgetg(1,t_VEC); rnf[10]= (long)nf; rnf[5] = (long)rnfmakematrices(rnf); | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES); | rnf[11] = (long)rnfequation2(nf,pol); if (DEBUGLEVEL>1) msgtimer("rnfequation"); M = modulereltoabs(rnf, bas); M = vecpol_to_mat(Q_remove_denom(M, &p1), lg(M)-1); if (p1) M = gdiv(hnfcenter_ip(hnfmodid(M, p1)), p1); else M = idmat(lg(M)-1); rnf[12] = (long)mat_to_vecpol(M,vpol); rnf[13] = (long)linvmat(M); if (DEBUGLEVEL>1) msgtimer("basabs"); return gerepilecopy(av, rnf); | rnfinitalg(GEN nf,GEN pol,long prec){ pari_sp av = avma; long m,n,r1,r2,vnf,i,j,k,vpol,degabs; GEN RES,sig,rac,liftpol,delta,RAC,ro,bas,f2,rnfeq,M, p1,p2,p3; if (typ(pol)!=t_POL) err(notpoler,"rnfinitalg"); nf=checknf(nf); n=degpol(pol); vpol=varn(pol); pol = fix_relative_pol(nf,pol,0); vnf = varn(nf[1]); if (vpol >= vnf) err(talker,"main variable must be of higher priority in rnfinitalg"); RES = cgetg(12,t_VEC); RES[1] = (long)pol; m = degpol(nf[1]); degabs = n*m; nf_get_sign(nf, &r1, &r2); sig = cgetg(r1+r2+1,t_VEC); RES[2] = (long)sig; RAC = cgetg(r1+r2+1,t_VEC); RES[6] = (long)RAC; rac = (GEN)nf[6]; liftpol = lift(pol); for (j=1; j<=r1; j++) { long r1j = 0; ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); while (r1j<n && gcmp0(gimag((GEN)ro[r1j+1]))) r1j++; p1 = cgetg(3,t_VEC); p1[1] = lstoi(r1j); p1[2] = lstoi((n-r1j)>>1); sig[j] = (long)p1; RAC[j] = (long)get_roots(ro, r1j, 0); } for (; j<=r1+r2; j++) { ro = roots(gsubst(liftpol,vnf,(GEN)rac[j]), prec); p1 = cgetg(3,t_VEC); p1[1] = zero; p1[2] = lstoi(n); sig[j] = (long)p1; RAC[j] = (long)ro; } p1 = rnfpseudobasis(nf,pol); delta = cgetg(3,t_VEC); delta[1] = p1[3]; delta[2] = p1[4]; RES[3] = (long)delta; p2 = matbasistoalg(nf,(GEN)p1[1]); bas = cgetg(3,t_VEC); bas[1] = (long)mat_to_vecpol(p2,vpol); bas[2] = (long)p1[2]; RES[7] = (long)bas; RES[8] = linvmat(p2); f2 = idealdiv(nf, discsr(pol), (GEN)p1[3]); RES[4] = (long)idealsqrtn(nf, f2, gdeux, 1); RES[9] = lgetg(1,t_VEC); /* multiplication table: dummy */ RES[10] = (long)nf; RES[5] = (long)rnfmakematrices(RES); if (DEBUGLEVEL>1) msgtimer("matrices"); rnfeq = rnfequation2(nf,pol); M = modulereltoabs(nf, rnfeq, bas); if (DEBUGLEVEL>1) msgtimer("M"); M = Q_remove_denom(M, &p3); if (p3) M = hnfmodid(M, p3); else M = idmat(degabs); for (j=degabs-1; j>0; j--) if (cmpis(gcoeff(M,j,j),2) > 0) { p1 = shifti(gcoeff(M,j,j),-1); for (k=j+1; k<=degabs; k++) if (cmpii(gcoeff(M,j,k),p1) > 0) for (i=1; i<=j; i++) coeff(M,i,k) = lsubii(gcoeff(M,i,k),gcoeff(M,i,j)); } if (p3) M = gdiv(M,p3); if (DEBUGLEVEL>1) msgtimer("hnfmod"); p1 = cgetg(6,t_VEC); RES[11] = (long)p1; for (i=1; i<=3; i++) p1[i] = rnfeq[i]; p1[4] = (long)mat_to_vecpol(M,vpol); p1[5] = linvmat(M); return gerepilecopy(av, RES);} |
TRUE, | ER cre_tsk( ID tskid, T_CTSK *pk_ctsk){ register Thread_Control *the_thread; boolean status; Priority_Control core_priority; /* * Validate Parameters. */ if ( pk_ctsk == NULL ) return E_PAR; if ((pk_ctsk->tskatr != TA_ASM ) && (pk_ctsk->tskatr != TA_HLNG) && (pk_ctsk->tskatr != TA_COP0) && (pk_ctsk->tskatr != TA_COP1) && (pk_ctsk->tskatr != TA_COP2) && (pk_ctsk->tskatr != TA_COP3) && (pk_ctsk->tskatr != TA_COP4) && (pk_ctsk->tskatr != TA_COP5) && (pk_ctsk->tskatr != TA_COP6) && (pk_ctsk->tskatr != TA_COP7)) return E_RSATR; if (( pk_ctsk->itskpri <= 0 ) || ( pk_ctsk->itskpri >= 256 )) return E_PAR; if ( pk_ctsk->task == NULL ) return E_PAR; if ( pk_ctsk->stksz < 0 ) return E_PAR; /* * Disable dispatching. */ _Thread_Disable_dispatch(); /* * allocate the thread. */ the_thread = _ITRON_Task_Allocate( tskid ); if ( !the_thread ) _ITRON_return_errorno( _ITRON_Task_Clarify_allocation_id_error( tskid ) ); /* * Initialize the core thread for this task. */ core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri ); status = _Thread_Initialize( &_ITRON_Task_Information, the_thread, NULL, pk_ctsk->stksz, TRUE, /* XXX - All tasks FP for now */ core_priority, TRUE, THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, NULL, /* no budget algorithm callout */ 0, NULL ); if ( !status ) { _ITRON_Task_Free( the_thread ); _ITRON_return_errorno( E_NOMEM ); } /* * This insures we evaluate the process-wide signals pending when we * first run. * * NOTE: Since the thread starts with all unblocked, this is necessary. */ the_thread->do_post_task_switch_extension = TRUE; the_thread->Start.entry_point = (Thread_Entry) pk_ctsk->task; _ITRON_return_errorno( E_OK );} |
|
long d = degpol(x[1]); | GEN z, X = (GEN)x[1]; long d = degpol(X); | gconj(GEN x){ long lx, i, tx = typ(x); GEN z; switch(tx) { case t_INT: case t_REAL: case t_INTMOD: case t_FRAC: case t_PADIC: return gcopy(x); case t_COMPLEX: z = cgetg(3,t_COMPLEX); z[1] = lcopy((GEN)x[1]); z[2] = lneg((GEN)x[2]); break; case t_QUAD: z = cgetg(4,t_QUAD); copyifstack(x[1],z[1]); z[2] = gcmp0(gmael(x,1,3))? lcopy((GEN)x[2]) : ladd((GEN)x[2], (GEN)x[3]); z[3] = lneg((GEN) x[3]); break; case t_POL: case t_SER: lx = lg(x); z = cgetg(lx,tx); z[1] = x[1]; for (i=2; i<lx; i++) z[i] = lconj((GEN)x[i]); break; case t_RFRAC: case t_VEC: case t_COL: case t_MAT: lx = lg(x); z = cgetg(lx,tx); for (i=1; i<lx; i++) z[i] = lconj((GEN)x[i]); break; case t_POLMOD: { long d = degpol(x[1]); if (d < 2) return gcopy(x); if (d == 2) { pari_sp av = avma; return gerepileupto(av, gadd(gtrace(x), gneg(x))); } } default: err(typeer,"gconj"); return NULL; /* not reached */ } return z;} |
if (d == 2) { pari_sp av = avma; return gerepileupto(av, gadd(gtrace(x), gneg(x))); | if (d == 2) { z = cgetg(3, t_POLMOD); copyifstack(X, z[1]); z[2] = (long)quad_polmod_conj((GEN)x[2], X); return z; | gconj(GEN x){ long lx, i, tx = typ(x); GEN z; switch(tx) { case t_INT: case t_REAL: case t_INTMOD: case t_FRAC: case t_PADIC: return gcopy(x); case t_COMPLEX: z = cgetg(3,t_COMPLEX); z[1] = lcopy((GEN)x[1]); z[2] = lneg((GEN)x[2]); break; case t_QUAD: z = cgetg(4,t_QUAD); copyifstack(x[1],z[1]); z[2] = gcmp0(gmael(x,1,3))? lcopy((GEN)x[2]) : ladd((GEN)x[2], (GEN)x[3]); z[3] = lneg((GEN) x[3]); break; case t_POL: case t_SER: lx = lg(x); z = cgetg(lx,tx); z[1] = x[1]; for (i=2; i<lx; i++) z[i] = lconj((GEN)x[i]); break; case t_RFRAC: case t_VEC: case t_COL: case t_MAT: lx = lg(x); z = cgetg(lx,tx); for (i=1; i<lx; i++) z[i] = lconj((GEN)x[i]); break; case t_POLMOD: { long d = degpol(x[1]); if (d < 2) return gcopy(x); if (d == 2) { pari_sp av = avma; return gerepileupto(av, gadd(gtrace(x), gneg(x))); } } default: err(typeer,"gconj"); return NULL; /* not reached */ } return z;} |
if (gcmp0(x)) return zero_gcd(y, x, ty, tx); if (gcmp0(y)) return zero_gcd(x, y, tx, ty); | if (isexactzero(x)) return zero_gcd(y, x, ty, tx); if (isexactzero(y)) return zero_gcd(x, y, tx, ty); | ggcd(GEN x, GEN y){ long l, i, vx, vy, tx = typ(x), ty = typ(y); pari_sp av, tetpil; GEN p1,z; if (tx>ty) { swap(x,y); lswap(tx,ty); } if (is_matvec_t(ty)) { if (is_noncalc_t(tx)) err(operf,"g",x,y); /* necessary if l = 1 */ l = lg(y); z = cgetg(l,ty); for (i=1; i<l; i++) gel(z,i) = ggcd(x,gel(y,i)); return z; } if (is_noncalc_t(tx) || is_noncalc_t(ty)) err(operf,"g",x,y); if (gcmp0(x)) return zero_gcd(y, x, ty, tx); if (gcmp0(y)) return zero_gcd(x, y, tx, ty); if (is_const_t(tx)) { if (ty == tx) switch(tx) { case t_INT: return gcdii(x,y); case t_INTMOD: z=cgetg(3,t_INTMOD); if (equalii(gel(x,1),gel(y,1))) copyifstack(x[1],z[1]); else gel(z,1) = gcdii(gel(x,1),gel(y,1)); if (gcmp1(gel(z,1))) gel(z,2) = gen_0; else { av = avma; p1 = gcdii(gel(z,1),gel(x,2)); if (!is_pm1(p1)) p1 = gerepileuptoint(av, gcdii(p1,gel(y,2))); gel(z,2) = p1; } return z; case t_FRAC: z=cgetg(3,t_FRAC); gel(z,1) = gcdii(gel(x,1), gel(y,1)); gel(z,2) = lcmii(gel(x,2), gel(y,2)); return z; case t_COMPLEX: if (c_is_rational(x) && c_is_rational(y)) return gauss_gcd(x,y); return triv_cont_gcd(y,x); case t_PADIC: if (!equalii(gel(x,2),gel(y,2))) return gen_1; vx = valp(x); vy = valp(y); return powiu(gel(y,2), min(vy,vx)); case t_QUAD: av=avma; p1=gdiv(x,y); if (gcmp0(gel(p1,3))) { p1=gel(p1,2); if (typ(p1)==t_INT) { avma=av; return gcopy(y); } tetpil=avma; return gerepile(av,tetpil, gdiv(y,gel(p1,2))); } if (typ(p1[2])==t_INT && typ(p1[3])==t_INT) {avma=av; return gcopy(y);} p1 = ginv(p1); avma=av; if (typ(p1[2])==t_INT && typ(p1[3])==t_INT) return gcopy(x); return triv_cont_gcd(y,x); default: return gen_1; /* t_REAL */ } if (is_const_t(ty)) switch(tx) { case t_INT: switch(ty) { case t_INTMOD: z = cgetg(3,t_INTMOD); copyifstack(y[1],z[1]); av=avma; p1 = gcdii(gel(y,1),gel(y,2)); if (!is_pm1(p1)) p1 = gerepileuptoint(av, gcdii(x,p1)); gel(z,2) = p1; return z; case t_FRAC: z = cgetg(3,t_FRAC); gel(z,1) = gcdii(x,gel(y,1)); gel(z,2) = icopy(gel(y,2)); return z; case t_COMPLEX: if (c_is_rational(y)) return gauss_gcd(x,y); case t_QUAD: return triv_cont_gcd(y,x); case t_PADIC: return padic_gcd(x,y); default: return gen_1; /* t_REAL */ } case t_INTMOD: switch(ty) { case t_FRAC: av = avma; p1=gcdii(gel(x,1),gel(y,2)); avma = av; if (!is_pm1(p1)) err(operi,"g",x,y); return ggcd(gel(y,1), x); case t_COMPLEX: case t_QUAD: return triv_cont_gcd(y,x); case t_PADIC: return padic_gcd(x,y); } case t_FRAC: switch(ty) { case t_COMPLEX: if (c_is_rational(y)) return gauss_gcd(x,y); case t_QUAD: return triv_cont_gcd(y,x); case t_PADIC: return padic_gcd(x,y); } case t_COMPLEX: /* ty = PADIC or QUAD */ return triv_cont_gcd(x,y); case t_PADIC: /* ty = QUAD */ return triv_cont_gcd(y,x); default: return gen_1; /* tx = t_REAL */ } return cont_gcd(y,x); } vx = gvar9(x); vy = gvar9(y); if (varncmp(vy, vx) < 0) return cont_gcd(y,x); if (varncmp(vy, vx) > 0) return cont_gcd(x,y); switch(tx) { case t_POLMOD: switch(ty) { case t_POLMOD: z=cgetg(3,t_POLMOD); if (gequal(gel(x,1),gel(y,1))) copyifstack(x[1],z[1]); else gel(z,1) = ggcd(gel(x,1),gel(y,1)); if (lg(z[1])<=3) gel(z,2) = gen_0; else { av=avma; p1=ggcd(gel(z,1),gel(x,2)); if (lg(p1)>3) { tetpil=avma; p1=gerepile(av,tetpil,ggcd(p1,gel(y,2))); } gel(z,2) = p1; } return z; case t_POL: z=cgetg(3,t_POLMOD); copyifstack(x[1],z[1]); av=avma; p1=ggcd(gel(x,1),gel(x,2)); if (lg(p1)>3) { tetpil=avma; p1=gerepile(av,tetpil,ggcd(y,p1)); } gel(z,2) = p1; return z; case t_RFRAC: av = avma; p1=ggcd(gel(x,1),gel(y,2)); avma = av; if (!gcmp1(p1)) err(operi,"g",x,y); return ggcd(gel(y,1),x); } break; case t_POL: switch(ty) { case t_POL: return srgcd(x,y); case t_SER: return monomial(gen_1, min(valp(y),gval(x,vx)), vx); case t_RFRAC: z=cgetg(3,ty); gel(z,1) = ggcd(x,gel(y,1)); gel(z,2) = gcopy(gel(y,2)); return z; } break; case t_SER: switch(ty) { case t_SER: return monomial(gen_1, min(valp(x),valp(y)), vx); case t_RFRAC: return monomial(gen_1, min(valp(x),gval(y,vx)), vx); } break; case t_RFRAC: z=cgetg(3,t_RFRAC); if (ty != t_RFRAC) err(operf,"g",x,y); p1 = gdiv(gel(y,2), ggcd(gel(x,2), gel(y,2))); tetpil = avma; gel(z,2) = gerepile((pari_sp)z,tetpil,gmul(p1, gel(x,2))); gel(z,1) = ggcd(gel(x,1), gel(y,1)); return z; } err(operf,"g",x,y); return NULL; /* not reached */} |
if (cbach == 0.) err(talker,"Bach constant = 0 in bnfxxx"); | if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, KCCO, LIMC, LIMC2, lim, zc, i, j, k, jid, MAXRELSUP; long nreldep, sfb_change, sfb_trials, nlze = 0, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN M, res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int RELSUP = 5, minsFB = 3; REL_t *rel, *oldrel; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach == 0.) err(talker,"Bach constant = 0 in bnfxxx"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; KCCO = F.KC+RU-1 + RELSUP; /* expected # of needed relations */ if (DEBUGLEVEL) fprintferr("KCZ = %ld, KC = %ld, KCCO = %ld\n", F.KCZ, F.KC, KCCO); MAXRELSUP = min(50, 4*F.KC); reallocate(&cache, 10*KCCO + MAXRELSUP); /* make room for lots of relations */ oldrel = cache.last; rel = oldrel + 1; for (i=1; i<=F.KCZ; i++) { /* trivial relations (p) = prod P^e */ long p = F.FB[i]; GEN c, P = F.LV[p]; if (!isclone(P)) continue; /* all prime divisors in FB */ c = col_0(F.KC); k = F.iLP[p]; rel->nz = k+1; rel->R = c; c += k; rel->ex = NULL; rel->m = NULL; rel->pow= NULL; /* = F.pow */ for (j = lg(P)-1; j; j--) c[j] = itos(gmael(P,j,3)); rel++; } cache.last = rel - 1; if (DEBUGLEVEL) fprintferr("After trivial relations, cglob = %ld\n", cache.last - cache.base); /* initialize for other relations */ cache.end = cache.base + KCCO; /* Relations through elements of small norm */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = sfb_change = nreldep = 0; if (cache.last < cache.end) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (++nreldep > MAXRELSUP) { sfb_change = 2; if (++sfb_trials > SFB_MAX) goto START; } if (sfb_change) { if (DEBUGLEVEL) fprintferr("*** Changing sub factor base\n"); if (!subFB_increase(&F, nf, sfb_change-1, L_jid)) goto START; jid = sfb_change = nreldep = 0; } if (W) { /* reduced relation matrix at least once */ long lgex = max(nlze, MIN_EXTRA); /* # of new relations sought */ size_t slim = (cache.last - cache.base) + lgex; if (slim > cache.len) reallocate(&cache, slim << 1); cache.end = cache.base + slim; oldrel = cache.last; if (DEBUGLEVEL) fprintferr("\n(need %ld more relation%s)\n", lgex, (lgex==1)?"":"s"); } if (!vecG) { vecG = compute_vecG(nf); av2 = avma; } if (!F.pow && !powFBgen(&F, &cache, nf, CBUCHG+1)) sfb_change = 1; if (!sfb_change) { if (!rnd_rel(&cache,&F, MAXRELSUP,nf,vecG,L_jid,&jid)) goto START; if (W) { if (jid == F.KC) jid = 1; else jid++; } } L_jid = NULL; }PRECPB: if (precpb) { precdouble++; if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; oldrel = cache.base; /* recompute all arch component */ precpb = NULL; W = NULL; } /* Reduce relation matrices */ M = gmael(nf, 5, 1); if (F.pow && !F.pow->arc) powFB_fill(&cache, M); { long l = cache.last - oldrel, j; GEN mat = cgetg(l+1, t_VEC), emb = cgetg(l+1, t_MAT); for (j=1,rel = oldrel + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (!W) { /* never reduced before */ C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else /* update */ W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); } gerepileall(av2, 4, &W,&C,&B,&dep); nlze = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (nlze) { /* dependent rows */ if (nlze > 5) { if (cache.last - cache.base > 600 && nlze > 20) sfb_change = 1; L_jid = vecextract_i(F.perm, 1, nlze); vecsmall_sort(L_jid); jid = 0; } goto MORE; } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_PRECI: /* precision problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; case fupb_RELAT: /* not enough relations */ goto MORE; } /* DONE */ if (!be_honest(&F, nf)) goto START; F.KCZ2 = 0; /* be honest only once ! */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf,&A,flun,&e,PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
if (tx == t_SER) return x; if (tx != t_POL) err(talker,"bad argument for modular function"); return tayl(x,gvar(x),precdl); | if (! ( x = _toser(x)) ) err(talker,"bad argument for modular function"); return x; | qq(GEN x, long prec){ long tx=typ(x); if (tx==t_PADIC) return x; if (is_scalar_t(tx)) { long l = precision(x); if (!l) l = prec; if (tx != t_COMPLEX || gsigne((GEN)x[2]) <= 0) err(talker,"argument must belong to upper half-plane"); return gexp(gmul(x, PiI2(l)), l); /* e(x) */ } if (tx == t_SER) return x; if (tx != t_POL) err(talker,"bad argument for modular function"); return tayl(x,gvar(x),precdl);} |
unsigned32 size; | uint32_t size; | rtems_monitor_server_task( rtems_task_argument monitor_flags){ rtems_monitor_server_request_t request; rtems_monitor_server_response_t response; rtems_status_code status; unsigned32 size; for (;;) { status = rtems_message_queue_receive( rtems_monitor_server_request_queue_id, &request, &size, RTEMS_WAIT, (rtems_interval) 0); if (status != RTEMS_SUCCESSFUL) { rtems_error(status, "monitor server msg queue receive error"); goto failed; } if (size != sizeof(request)) { rtems_error(0, "monitor server bad size on receive"); goto failed; } switch (request.command) { case RTEMS_MONITOR_SERVER_CANONICAL: { rtems_monitor_object_type_t object_type; rtems_id id; rtems_id next_id; object_type = (rtems_monitor_object_type_t) request.argument0; id = (rtems_id) request.argument1; next_id = rtems_monitor_object_canonical_get(object_type, id, &response.payload, &size); response.command = RTEMS_MONITOR_SERVER_RESPONSE; response.result0 = next_id; response.result1 = size;#define SERVER_OVERHEAD (RTEMS_offsetof(rtems_monitor_server_response_t, \ payload)) status = rtems_message_queue_send(request.return_id, &response, size + SERVER_OVERHEAD); if (status != RTEMS_SUCCESSFUL) { rtems_error(status, "response send failed"); goto failed; } break; } default: { rtems_error(0, "invalid command to monitor server: %d", request.command); goto failed; } } }failed: rtems_task_delete(RTEMS_SELF);} |
rtems_unsigned32 remove_task; rtems_unsigned32 task; rtems_unsigned32 block; rtems_unsigned32 task_count = 0; | uint32_t remove_task; uint32_t task; uint32_t block; uint32_t task_count = 0; | void test2(){ rtems_status_code result; rtems_unsigned32 remove_task; rtems_unsigned32 task; rtems_unsigned32 block; rtems_unsigned32 task_count = 0; rtems_id removed_ids[TASK_ALLOCATION_SIZE * 2]; char c1 = 'a'; char c2 = 'a'; char c3 = '0'; char c4 = '0'; printf( "\n TEST2 : re-allocate of index numbers, and a block free'ed and one inactive\n" ); /* * Allocate enought tasks so the Inactive list is empty. Remember * to count the Init task, ie ... - 1. */ while (task_count < ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { rtems_name name; printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[task_count]); if (status_code_bad(result)) break; printf("number = %3i, id = %08x, starting, ", task_count, task_id[task_count]); fflush(stdout); result = rtems_task_start(task_id[task_count], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) break; /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); task_count++; } /* * Take out the second and fourth allocation size block of tasks */ if (task_count != ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { printf( " FAIL2 : not enough tasks created -\n" " task created = %i, required number = %i\n", task_count, (TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET); destory_all_tasks("TEST2"); exit( 1 ); } task = 0; for (block = 1; block < 4; block += 2) { for (remove_task = (block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET; remove_task < (((block + 1) * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET); remove_task++) { if (!task_id[remove_task]) { printf( " FAIL2 : remove task has a 0 id -\n" " task number = %i\n", remove_task); destory_all_tasks("TEST2"); exit( 1 ); } /* * Save the id's to match them against the reallocated ids */ removed_ids[task++] = task_id[remove_task]; printf(" TEST2 : block %i remove, signal task %08x, ", block, task_id[remove_task]); rtems_event_send(task_id[remove_task], 1); task_id[remove_task] = 0; } } for (task = 0; task < (TASK_ALLOCATION_SIZE * 2); task++) { rtems_name name; rtems_unsigned32 id_slot; /* * Find a free slot in the task id table. */ for (id_slot = 0; id_slot < MAX_TASKS; id_slot++) if (!task_id[id_slot]) break; if (id_slot == MAX_TASKS) { printf( " FAIL2 : no free task id slot.\n"); destory_all_tasks("TEST2"); exit( 1 ); } printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[id_slot]); if (status_code_bad(result)) { printf( " FAIL2 : re-creating a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } printf("number = %3i, id = %08x, starting, ", task_count, task_id[id_slot]); result = rtems_task_start(task_id[id_slot], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) { printf( " FAIL : re-starting a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); /* * Search the removed ids to see if it existed, clear the removed id when found */ for (remove_task = 0; remove_task < (TASK_ALLOCATION_SIZE * 2); remove_task++) if (removed_ids[remove_task] == task_id[id_slot]) { removed_ids[remove_task] = 0; break; } /* * If not located in the removed id table, check and make sure it is not * already allocated */ if (remove_task == (TASK_ALLOCATION_SIZE * 2)) { rtems_unsigned32 allocated_id; for (allocated_id = 0; allocated_id < MAX_TASKS; allocated_id++) if ((task_id[id_slot] == task_id[allocated_id]) && (id_slot != allocated_id)) { printf( " FAIL2 : the new id is the same as an id already allocated -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } printf( " FAIL2 : could not find the task id in the removed table -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } task_count++; } destory_all_tasks("TEST2"); printf( " TEST2 : completed\n" );} |
rtems_unsigned32 id_slot; | uint32_t id_slot; | void test2(){ rtems_status_code result; rtems_unsigned32 remove_task; rtems_unsigned32 task; rtems_unsigned32 block; rtems_unsigned32 task_count = 0; rtems_id removed_ids[TASK_ALLOCATION_SIZE * 2]; char c1 = 'a'; char c2 = 'a'; char c3 = '0'; char c4 = '0'; printf( "\n TEST2 : re-allocate of index numbers, and a block free'ed and one inactive\n" ); /* * Allocate enought tasks so the Inactive list is empty. Remember * to count the Init task, ie ... - 1. */ while (task_count < ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { rtems_name name; printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[task_count]); if (status_code_bad(result)) break; printf("number = %3i, id = %08x, starting, ", task_count, task_id[task_count]); fflush(stdout); result = rtems_task_start(task_id[task_count], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) break; /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); task_count++; } /* * Take out the second and fourth allocation size block of tasks */ if (task_count != ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { printf( " FAIL2 : not enough tasks created -\n" " task created = %i, required number = %i\n", task_count, (TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET); destory_all_tasks("TEST2"); exit( 1 ); } task = 0; for (block = 1; block < 4; block += 2) { for (remove_task = (block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET; remove_task < (((block + 1) * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET); remove_task++) { if (!task_id[remove_task]) { printf( " FAIL2 : remove task has a 0 id -\n" " task number = %i\n", remove_task); destory_all_tasks("TEST2"); exit( 1 ); } /* * Save the id's to match them against the reallocated ids */ removed_ids[task++] = task_id[remove_task]; printf(" TEST2 : block %i remove, signal task %08x, ", block, task_id[remove_task]); rtems_event_send(task_id[remove_task], 1); task_id[remove_task] = 0; } } for (task = 0; task < (TASK_ALLOCATION_SIZE * 2); task++) { rtems_name name; rtems_unsigned32 id_slot; /* * Find a free slot in the task id table. */ for (id_slot = 0; id_slot < MAX_TASKS; id_slot++) if (!task_id[id_slot]) break; if (id_slot == MAX_TASKS) { printf( " FAIL2 : no free task id slot.\n"); destory_all_tasks("TEST2"); exit( 1 ); } printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[id_slot]); if (status_code_bad(result)) { printf( " FAIL2 : re-creating a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } printf("number = %3i, id = %08x, starting, ", task_count, task_id[id_slot]); result = rtems_task_start(task_id[id_slot], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) { printf( " FAIL : re-starting a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); /* * Search the removed ids to see if it existed, clear the removed id when found */ for (remove_task = 0; remove_task < (TASK_ALLOCATION_SIZE * 2); remove_task++) if (removed_ids[remove_task] == task_id[id_slot]) { removed_ids[remove_task] = 0; break; } /* * If not located in the removed id table, check and make sure it is not * already allocated */ if (remove_task == (TASK_ALLOCATION_SIZE * 2)) { rtems_unsigned32 allocated_id; for (allocated_id = 0; allocated_id < MAX_TASKS; allocated_id++) if ((task_id[id_slot] == task_id[allocated_id]) && (id_slot != allocated_id)) { printf( " FAIL2 : the new id is the same as an id already allocated -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } printf( " FAIL2 : could not find the task id in the removed table -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } task_count++; } destory_all_tasks("TEST2"); printf( " TEST2 : completed\n" );} |
rtems_unsigned32 allocated_id; | uint32_t allocated_id; | void test2(){ rtems_status_code result; rtems_unsigned32 remove_task; rtems_unsigned32 task; rtems_unsigned32 block; rtems_unsigned32 task_count = 0; rtems_id removed_ids[TASK_ALLOCATION_SIZE * 2]; char c1 = 'a'; char c2 = 'a'; char c3 = '0'; char c4 = '0'; printf( "\n TEST2 : re-allocate of index numbers, and a block free'ed and one inactive\n" ); /* * Allocate enought tasks so the Inactive list is empty. Remember * to count the Init task, ie ... - 1. */ while (task_count < ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { rtems_name name; printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[task_count]); if (status_code_bad(result)) break; printf("number = %3i, id = %08x, starting, ", task_count, task_id[task_count]); fflush(stdout); result = rtems_task_start(task_id[task_count], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) break; /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); task_count++; } /* * Take out the second and fourth allocation size block of tasks */ if (task_count != ((TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET)) { printf( " FAIL2 : not enough tasks created -\n" " task created = %i, required number = %i\n", task_count, (TASK_ALLOCATION_SIZE * 5) - TASK_INDEX_OFFSET); destory_all_tasks("TEST2"); exit( 1 ); } task = 0; for (block = 1; block < 4; block += 2) { for (remove_task = (block * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET; remove_task < (((block + 1) * TASK_ALLOCATION_SIZE) - TASK_INDEX_OFFSET); remove_task++) { if (!task_id[remove_task]) { printf( " FAIL2 : remove task has a 0 id -\n" " task number = %i\n", remove_task); destory_all_tasks("TEST2"); exit( 1 ); } /* * Save the id's to match them against the reallocated ids */ removed_ids[task++] = task_id[remove_task]; printf(" TEST2 : block %i remove, signal task %08x, ", block, task_id[remove_task]); rtems_event_send(task_id[remove_task], 1); task_id[remove_task] = 0; } } for (task = 0; task < (TASK_ALLOCATION_SIZE * 2); task++) { rtems_name name; rtems_unsigned32 id_slot; /* * Find a free slot in the task id table. */ for (id_slot = 0; id_slot < MAX_TASKS; id_slot++) if (!task_id[id_slot]) break; if (id_slot == MAX_TASKS) { printf( " FAIL2 : no free task id slot.\n"); destory_all_tasks("TEST2"); exit( 1 ); } printf(" TEST2 : creating task '%c%c%c%c', ", c1, c2, c3, c4); name = rtems_build_name(c1, c2, c3, c4); result = rtems_task_create(name, 10, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_LOCAL, &task_id[id_slot]); if (status_code_bad(result)) { printf( " FAIL2 : re-creating a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } printf("number = %3i, id = %08x, starting, ", task_count, task_id[id_slot]); result = rtems_task_start(task_id[id_slot], test_task, (rtems_task_argument) task_count); if (status_code_bad(result)) { printf( " FAIL : re-starting a task -\n" " task number = %i\n", id_slot); destory_all_tasks("TEST2"); exit( 1 ); } /* * Update the name. */ NEXT_TASK_NAME(c1, c2, c3, c4); /* * Search the removed ids to see if it existed, clear the removed id when found */ for (remove_task = 0; remove_task < (TASK_ALLOCATION_SIZE * 2); remove_task++) if (removed_ids[remove_task] == task_id[id_slot]) { removed_ids[remove_task] = 0; break; } /* * If not located in the removed id table, check and make sure it is not * already allocated */ if (remove_task == (TASK_ALLOCATION_SIZE * 2)) { rtems_unsigned32 allocated_id; for (allocated_id = 0; allocated_id < MAX_TASKS; allocated_id++) if ((task_id[id_slot] == task_id[allocated_id]) && (id_slot != allocated_id)) { printf( " FAIL2 : the new id is the same as an id already allocated -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } printf( " FAIL2 : could not find the task id in the removed table -\n" " task id = %08x\n", task_id[id_slot]); exit( 1 ); } task_count++; } destory_all_tasks("TEST2"); printf( " TEST2 : completed\n" );} |
if (signe(c0)) { c0 = addmulXn(c0, c2, n0); c0 = addmulXncopy(c0,c,n0); } | c0 = addmulXn(c0, c2, n0); | quickmul(GEN a, GEN b, long na, long nb){ GEN a0,c,c0; long n0, n0a, i, v = 0; pari_sp av; while (na && isexactzero((GEN)a[0])) { a++; na--; v++; } while (nb && isexactzero((GEN)b[0])) { b++; nb--; v++; } if (na < nb) swapspec(a,b, na,nb); if (!nb) return zeropol(0); if (v) (void)cgetg(v,t_STR); /* v gerepile-safe cells for shiftpol_ip */ if (nb < MUL_LIMIT) return shiftpol_ip(mulpol(a,b,na,nb), v); i=(na>>1); n0=na-i; na=i; av=avma; a0=a+n0; n0a=n0; while (n0a && isexactzero((GEN)a[n0a-1])) n0a--; if (nb > n0) { GEN b0,c1,c2; long n0b; nb -= n0; b0 = b+n0; n0b = n0; while (n0b && isexactzero((GEN)b[n0b-1])) n0b--; c = quickmul(a,b,n0a,n0b); c0 = quickmul(a0,b0, na,nb); c2 = addpol(a0,a, na,n0a); c1 = addpol(b0,b, nb,n0b); c1 = quickmul(c1+2,c2+2, lgpol(c1),lgpol(c2)); c2 = gadd(c1, gneg_i(gadd(c0,c))); if (signe(c0)) { c0 = addmulXn(c0, c2, n0); c0 = addmulXncopy(c0,c,n0); } } else { c = quickmul(a,b,n0a,nb); c0 = quickmul(a0,b,na,nb); if (signe(c0)) c0 = addmulXncopy(c0,c,n0); } return shiftpol_ip(gerepileupto(av,c0), v);} |
if (signe(c0)) c0 = addmulXncopy(c0,c,n0); | quickmul(GEN a, GEN b, long na, long nb){ GEN a0,c,c0; long n0, n0a, i, v = 0; pari_sp av; while (na && isexactzero((GEN)a[0])) { a++; na--; v++; } while (nb && isexactzero((GEN)b[0])) { b++; nb--; v++; } if (na < nb) swapspec(a,b, na,nb); if (!nb) return zeropol(0); if (v) (void)cgetg(v,t_STR); /* v gerepile-safe cells for shiftpol_ip */ if (nb < MUL_LIMIT) return shiftpol_ip(mulpol(a,b,na,nb), v); i=(na>>1); n0=na-i; na=i; av=avma; a0=a+n0; n0a=n0; while (n0a && isexactzero((GEN)a[n0a-1])) n0a--; if (nb > n0) { GEN b0,c1,c2; long n0b; nb -= n0; b0 = b+n0; n0b = n0; while (n0b && isexactzero((GEN)b[n0b-1])) n0b--; c = quickmul(a,b,n0a,n0b); c0 = quickmul(a0,b0, na,nb); c2 = addpol(a0,a, na,n0a); c1 = addpol(b0,b, nb,n0b); c1 = quickmul(c1+2,c2+2, lgpol(c1),lgpol(c2)); c2 = gadd(c1, gneg_i(gadd(c0,c))); if (signe(c0)) { c0 = addmulXn(c0, c2, n0); c0 = addmulXncopy(c0,c,n0); } } else { c = quickmul(a,b,n0a,nb); c0 = quickmul(a0,b,na,nb); if (signe(c0)) c0 = addmulXncopy(c0,c,n0); } return shiftpol_ip(gerepileupto(av,c0), v);} |
|
c0 = addmulXncopy(c0,c,n0); | quickmul(GEN a, GEN b, long na, long nb){ GEN a0,c,c0; long n0, n0a, i, v = 0; pari_sp av; while (na && isexactzero((GEN)a[0])) { a++; na--; v++; } while (nb && isexactzero((GEN)b[0])) { b++; nb--; v++; } if (na < nb) swapspec(a,b, na,nb); if (!nb) return zeropol(0); if (v) (void)cgetg(v,t_STR); /* v gerepile-safe cells for shiftpol_ip */ if (nb < MUL_LIMIT) return shiftpol_ip(mulpol(a,b,na,nb), v); i=(na>>1); n0=na-i; na=i; av=avma; a0=a+n0; n0a=n0; while (n0a && isexactzero((GEN)a[n0a-1])) n0a--; if (nb > n0) { GEN b0,c1,c2; long n0b; nb -= n0; b0 = b+n0; n0b = n0; while (n0b && isexactzero((GEN)b[n0b-1])) n0b--; c = quickmul(a,b,n0a,n0b); c0 = quickmul(a0,b0, na,nb); c2 = addpol(a0,a, na,n0a); c1 = addpol(b0,b, nb,n0b); c1 = quickmul(c1+2,c2+2, lgpol(c1),lgpol(c2)); c2 = gadd(c1, gneg_i(gadd(c0,c))); if (signe(c0)) { c0 = addmulXn(c0, c2, n0); c0 = addmulXncopy(c0,c,n0); } } else { c = quickmul(a,b,n0a,nb); c0 = quickmul(a0,b,na,nb); if (signe(c0)) c0 = addmulXncopy(c0,c,n0); } return shiftpol_ip(gerepileupto(av,c0), v);} |
|
rtems_unsigned32 isr_level; | uint32_t isr_level; | void Shm_Unlock( Shm_Locked_queue_Control *lq_cb){ rtems_unsigned32 isr_level; lq_cb->lock = SHM_UNLOCK_VALUE; isr_level = Shm_isrstat; rtems_interrupt_enable( isr_level );} |
affrr(p2,y); return y; | affr_fixlg(p2,y); return y; | mpsc1(GEN x, long *ptmod8){ long e = expo(x), l = lg(x), l1, l2, i, n, m, s; pari_sp av; double beta, a, b, d; GEN y, unr, p2, p1, x2; n = 0; if (e > 0) { GEN q, z, pitemp = mppi(DEFAULTPREC + (e >> TWOPOTBITS_IN_LONG)); setexpo(pitemp,-1); z = addrr(x,pitemp); /* = x + Pi/4 */ if (expo(z) >= bit_accuracy(min(l, lg(z))) + 3) err(precer,"mpsc1"); setexpo(pitemp, 0); q = floorr( divrr(z,pitemp) ); /* round ( x / (Pi/2) ) */ if (signe(q)) { x = subrr(x, mulir(q, Pi2n(-1, l+1))); /* x mod Pi/2 */ e = expo(x); n = mod4(q); if (n && signe(q) < 0) n = 4 - n; } } s = signe(x); *ptmod8 = (s < 0)? 4 + n: n; if (!s) return realzero_bit(-bit_accuracy(l)<<1); l = lg(x); l2 = l+1; y = cgetr(l); beta = 5. + bit_accuracy_mul(l2,LOG2); a = sqrt(beta / LOG2); d = a + 1/LOG2 - log2(a / (double)(ulong)x[2]) - (BITS_IN_LONG-1-e); if (d >= 0) { n = (long)((1+a) / 2.0); m = (long)(1+d); l2 += m>>TWOPOTBITS_IN_LONG; } else { /* rare ! */ b = -1 - log((double)(ulong)x[2]) + (BITS_IN_LONG-1-e)*LOG2; /*-1-log(x)*/ n = (long)(1 + beta/(2.0*b)); m = 0; } unr= realun(l2); p2 = realun(l2); x2 = cgetr(l2); av = avma; affrr(gsqr(x), x2); if (m) setexpo(x2, expo(x2) - (m<<1)); setlg(x2, 3); p1 = divrs(x2, 2*n+1); s = -expo(p1); l1 = 3 + (s>>TWOPOTBITS_IN_LONG); setlg(p2,l1); s = 0; for (i=n; i>=2; i--) { setlg(x2,l1); p1 = divrsns(x2, 2*i-1); s -= expo(p1); p1 = mulrr(p1,p2); l1 += s>>TWOPOTBITS_IN_LONG; if (l1>l2) l1=l2; s &= (BITS_IN_LONG-1); setlg(unr,l1); p1 = addrr_sign(unr,1, p1,-signe(p1)); setlg(p2,l1); affrr(p1,p2); avma = av; } p2[1] = evalsigne(-signe(p2)) | evalexpo(expo(p2)-1); /* p2 := -p2/2 */ setlg(p2,l2); setlg(x2,l2); p2 = mulrr(x2,p2); /* Now p2 = sum {1<= i <=n} (-1)^i x^(2i) / (2i)! ~ cos(x) - 1 */ for (i=1; i<=m; i++) { /* p2 = cos(x)-1 --> cos(2x)-1 */ setlg(p2,l2); p2 = mulrr(p2, addsr(2,p2)); setexpo(p2, expo(p2)+1); } affrr(p2,y); return y;} |
long i, l=lgpol(T); | long i, l=lgpol(T), ll=l+2; | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |
pari_sp av; | long v=T[1]; pari_sp av, av2; | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |
av = avma; | av=avma; new_chunk(ll<<1); av2=avma; | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |
new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); | x=Flx_sqr(x,p); x=Flx_renormalize(x,min(lg(x),ll)); z=Flx_mul(q,x,p); z=Flx_renormalize(z,min(lg(z),ll)); q=Flx_add(q,z,p); | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |
q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); | q=Flx_copy(q); x=Flx_copy(x); avma=av2; | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |
q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1); | q=Flx_mul(q,Flx_polx(v),p); return q; | Flx_invmontgomery_newton(GEN T, ulong p){ long i, l=lgpol(T); GEN x, q, z; pari_sp av; x = Flx_recipspec(T+2,l-1,l); x = Flx_neg(x,p); q = Flx_copy(x); q[2]=1; i = Flx_valuation(x); av = avma; for ( ; i<l; i<<=1) { new_chunk(l+2); x=Flx_sqrspec(x+2,p,l); z=Flx_mulspec(q+2,x+2,p,l,l); avma=av; /* We do full garbage collecting here since: * 1) T is assumed to be large (else we use basecase) * 2) This improve cache usage. * Note that due to valuation handling of x, * q*x+q is faster than q*(x+1) */ q=Flx_addspec(q+2,z+2,p,l,l); x=Flx_addspec(x+2,NULL,p,l,0); } q=Flx_mulspec(q+2,Flx_polx(0)+2,p,l,2); q[1]=T[1]; return Flx_renormalize(q,l+1);} |