Expr* const get(mpz_class index) { return constructor(f->get(index)); }
return ret; } void emul__exit(int status) { ret = status; longjmp(buf, status); } /* this is the NetBSD initial environ array; when we fully just use host environ this can go away */ /* it is not quite clear why it is not being initialised properly, we should call the initialiser... */ static char *the_env[1] = { NULL } ; void nullenv_init (void) __attribute__((constructor (102))); void nullenv_init() { _netbsd_environ = the_env; } int * emul__errno(void) { return &errno; } typedef int64_t _netbsd_time_t; typedef int _netbsd_suseconds_t;
/** Constructor. * Creates a colormap in shared memory for the given LUT ID and copies the data of the * given existing colormap. * @param cm existing colormap to copy data from * @param shmem_lut_id shared memory LUT ID * @param destroy_on_free true to delete the shared memory segment to delete, false to keep the segment */ YuvColormap::YuvColormap(YuvColormap *cm, const char *shmem_lut_id, bool destroy_on_free) { constructor(cm->depth(), cm->width(), cm->height(), shmem_lut_id, destroy_on_free); memcpy(lut_, cm->lut_, lut_size_); }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <data.h> #include <exception.h> #include <loader.h> #include <logging.h> #include <name.h> #include <namespace.h> #include <script.h> #include <testsuite.h> extern int File; static void _init_file(void) __attribute__((constructor(300))); static data_t * _file_open(char *); static data_t * _file_readline(data_t *); static data_t * _file_close(data_t *); data_t * _file_open(char *name) { data_t *dummy = data_create(Bool, 0); array_t *args = data_array_create(1); data_t *f; array_push(args, data_create(String, "file.txt")); f = data_execute(dummy, "open", args, NULL); array_free(args); data_free(dummy); return f; }
#include "Arduino.h" unsigned _stklen = 4096 * 1024; DPMI_MEMORY_ALL_LOCK(0) static __attribute__((constructor(101))) void _f_init() { init(); } static __attribute__((destructor(101))) void _f_final() { final(); }
ECode CPicture::constructor( /* [in] */ IPicture* src) { return constructor(NativeConstructor( src != NULL ? ((CPicture*)src)->mNativePicture : 0)); }
Semaphore::Semaphore(int32_t count) { constructor(count, 0xffff); }
void pushElement( const XMLElement& element ){ ASSERT_MESSAGE( string_equal( element.name(), "mapdoom3" ), PARSE_ERROR ); constructor( getEntity(), makeReference( m_root ), makeReference( m_entityTable ) ); }
ECode InsetDrawable::constructor() { return constructor((InsetState*)NULL, (IResources*)NULL); }
static void primaryexp (LexState *ls, expdesc *v) { /* primaryexp -> prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ FuncState *fs = ls->fs; prefixexp(ls, v); for (;;) { switch (ls->t.token) { case '.': { /* field */ field(ls, v); break; } case '[': { /* `[' exp1 `]' */ expdesc key; luaK_exp2anyreg(fs, v); yindex(ls, &key); luaK_indexed(fs, v, &key); break; } case ':': { /* `:' NAME funcargs */ expdesc key; luaX_next(ls); checkname(ls, &key); luaK_self(fs, v, &key); funcargs(ls, v); break; } #if LUA_WIDESTRING case '(': case TK_STRING: case TK_WSTRING: case '{': { /* funcargs */ #else case '(': case TK_STRING: case '{': { /* funcargs */ #endif /* LUA_WIDESTRING */ luaK_exp2nextreg(fs, v); funcargs(ls, v); break; } default: return; } } } static void simpleexp (LexState *ls, expdesc *v) { #if LUA_WIDESTRING /* simpleexp -> NUMBER | STRING | WSTRING | NIL | true | false | ... | constructor | FUNCTION body | primaryexp */ #else /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | constructor | FUNCTION body | primaryexp */ #endif /* LUA_WIDESTRING */ switch (ls->t.token) { case TK_NUMBER: { init_exp(v, VKNUM, 0); v->u.nval = ls->t.seminfo.r; break; } case TK_STRING: { codestring(ls, v, ls->t.seminfo.ts); break; } #if LUA_WIDESTRING case TK_WSTRING: { codewstring(ls, v, ls->t.seminfo.ts); break; } #endif /* LUA_WIDESTRING */ case TK_NIL: { init_exp(v, VNIL, 0); break; } case TK_TRUE: { init_exp(v, VTRUE, 0); break; } case TK_FALSE: { init_exp(v, VFALSE, 0); break; } case TK_DOTS: { /* vararg */ FuncState *fs = ls->fs; check_condition(ls, fs->f->is_vararg, "cannot use " LUA_QL("...") " outside a vararg function"); fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); break; } case '{': { /* constructor */ constructor(ls, v); return; } case TK_FUNCTION: { luaX_next(ls); body(ls, v, 0, ls->linenumber); return; } default: { primaryexp(ls, v); return; } } luaX_next(ls); } static UnOpr getunopr (int op) { switch (op) { case TK_NOT: return OPR_NOT; case '-': return OPR_MINUS; case '#': return OPR_LEN; default: return OPR_NOUNOPR; } } static BinOpr getbinopr (int op) { switch (op) { case '+': return OPR_ADD; case '-': return OPR_SUB; case '*': return OPR_MUL; case '/': return OPR_DIV; case '%': return OPR_MOD; #if LUA_BITFIELD_OPS case '&': return OPR_BAND; case '|': return OPR_BOR; case TK_XOR: return OPR_BXOR; case TK_SHL: return OPR_BSHL; case TK_SHR: return OPR_BSHR; #endif /* LUA_BITFIELD_OPS */ case '^': return OPR_POW; case TK_CONCAT: return OPR_CONCAT; case TK_NE: return OPR_NE; case TK_EQ: return OPR_EQ; case '<': return OPR_LT; case TK_LE: return OPR_LE; case '>': return OPR_GT; case TK_GE: return OPR_GE; case TK_AND: return OPR_AND; case TK_OR: return OPR_OR; default: return OPR_NOBINOPR; } } static const struct { lu_byte left; /* left priority for each binary operator */ lu_byte right; /* right priority */ } priority[] = { /* ORDER OPR */ #if LUA_BITFIELD_OPS {8, 8}, {8, 8}, {8, 8}, {8, 8}, {8, 8}, /* bitwise operators */ #endif /* LUA_BITFIELD_OPS */ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ {10, 9}, {5, 4}, /* power and concat (right associative) */ {3, 3}, {3, 3}, /* equality and inequality */ {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ {2, 2}, {1, 1} /* logical (and/or) */ }; #define UNARY_PRIORITY 8 /* priority for unary operators */ /* ** subexpr -> (simpleexp | unop subexpr) { binop subexpr } ** where `binop' is any binary operator with a priority higher than `limit' */ static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { BinOpr op; UnOpr uop; enterlevel(ls); uop = getunopr(ls->t.token); if (uop != OPR_NOUNOPR) { luaX_next(ls); subexpr(ls, v, UNARY_PRIORITY); luaK_prefix(ls->fs, uop, v); } else simpleexp(ls, v); /* expand while operators have priorities higher than `limit' */ op = getbinopr(ls->t.token); while (op != OPR_NOBINOPR && priority[op].left > limit) { expdesc v2; BinOpr nextop; luaX_next(ls); luaK_infix(ls->fs, op, v); /* read sub-expression with higher priority */ nextop = subexpr(ls, &v2, priority[op].right); luaK_posfix(ls->fs, op, v, &v2); op = nextop; } leavelevel(ls); return op; /* return first untreated operator */ }
void pushElement( const XMLElement& element ){ ASSERT_MESSAGE( string_equal( element.name(), "entity" ), PARSE_ERROR ); constructor( node(), NodeSmartReference( m_entityTable.createEntity( GlobalEntityClassManager().findOrInsert( "", true ) ) ) ); constructor( primitive(), makeReference( node().get() ) ); }
return -1; } if(hci_disconnect(dd, channels.channels[channel].handle, HCI_OE_USER_ENDED_CONNECTION, 5*HCI_REQ_TIMEOUT) < 0) { perror("hci_disconnect"); result = -1; } hci_close_dev(dd); return result; } static s_l2cap_abs l2cap_bluez = { .connect = l2cap_bluez_connect, .listen = l2cap_bluez_listen, .send = l2cap_bluez_send, .recv = l2cap_bluez_recv, .close = l2cap_bluez_close, .add_source = l2cap_bluez_add_source, .disconnect = l2cap_bluez_disconnect, }; void l2cap_bluez_init(void) __attribute__((constructor (101))); void l2cap_bluez_init(void) { l2cap_abs_register(E_BT_ABS_BLUEZ, &l2cap_bluez); }
int main( int argc, char *argv[] ) { const char *libname = "libui.so"; int classBuf[ 100 ]; int r1[ 10 ]; int r2[ 10 ]; int r3[ 10 ]; int jellybean = 0; int ( *unflatten )( int *r0, int *r1, int *r2, int *r3 ) = NULL; printf( "hello world\n" ); fflush( stdout ); void *handle = dlopen( libname, RTLD_NOW | RTLD_GLOBAL ); if( !handle ) { LOG_D( "error opening %s: %s\n", libname, dlerror() ); return -1; } bzero( classBuf, sizeof( classBuf ) ); bzero( r1, sizeof( r1 ) ); bzero( r2, sizeof( r2 ) ); bzero( r3, sizeof( r3 ) ); int ( *constructor )( int *r0 ) = dlsym( handle, "_ZN7android13GraphicBufferC2Ev" ); if( !constructor ) { LOG_D( "missing android::GraphicBuffer::GraphicBuffer(void)\n" ); return -1; } unflatten = dlsym( handle, "_ZN7android13GraphicBuffer9unflattenERPKvRjRPKiS4_" ); if( !unflatten ) { unflatten = dlsym( handle, "_ZN7android13GraphicBuffer9unflattenEPKvjPij" ); if( !unflatten ) { LOG_D( "missing android::GraphicBuffer::unflatten\n" ); return -1; } jellybean = 1; } constructor( classBuf ); // setup bad values int r1Ref = (int)(&r1[0]); // this must match r1[0] = 0x47424652; // size must be > 0x1f r2[0] = 0x20; // attempt to overflow r1[8] = 0x1000; r1[9] = 0xFF5; // make sure we error out on unpatched libs before getting to the point where we corrupt the heap r1[6] = 0x20; r1[7] = 0x20; int ret = 0; if( !jellybean ) { ret = unflatten( classBuf, &r1Ref, r2, r3 ); } else { int * val = (int*)(r2[0]); ret = unflatten( classBuf, r1, val, r3 ); } // -12 = unpatched 4.4.2 // -22 = patches 5.1.1 switch( ret ) { case -ENOMEM: printf( "unpatched\n" ); break; case -EINVAL: printf( "patched\n" ); break; default: printf( "test is broken ret: %d (%08x)\n", ret, ret ); break; } return 0; }
Expr* const get(mpz_class index) { return constructor( f1->get(index / f2->cardinal), f2->get(index % f2->cardinal)); }
ECode SparseBooleanArray::constructor() { return constructor(10); }
ECode InsetDrawable::constructor( /* [in] */ IDrawable* drawable, /* [in] */ Int32 inset) { return constructor(drawable, inset, inset, inset, inset); }
ECode CPicture::constructor() { return constructor(NativeConstructor(0)); }
void pHexEdit::orphan() { destructor(); constructor(); }
void pCanvas::orphan() { destructor(); constructor(); }
typedef void (*mm_free_t)(void*); typedef void* (*mm_calloc_t)(size_t nmemb, size_t size); typedef void* (*mm_realloc_t)(void *ptr, size_t size); /* Function pointers to the real/next implementations: */ static mm_malloc_t mm_real_malloc; static mm_free_t mm_real_free; static mm_calloc_t mm_real_calloc; static mm_realloc_t mm_real_realloc; static int mm_initializing; static int mm_initialized; /** Constructor functions used to initialize the malloc implementation */ static void __attribute__((constructor(101))) mm_legacy_constructor() { if (mm_initialized) return; mm_initializing = 1; __malloc_use_mmalloc = getenv(MC_ENV_VARIABLE) ? 1 : 0; if (__malloc_use_mmalloc) { __mmalloc_current_heap = mmalloc_preinit(); } else { mm_real_realloc = dlsym(RTLD_NEXT, "realloc"); mm_real_malloc = dlsym(RTLD_NEXT, "malloc"); mm_real_free = dlsym(RTLD_NEXT, "free"); mm_real_calloc = dlsym(RTLD_NEXT, "calloc"); } mm_initializing = 0; mm_initialized = 1;
Semaphore::Semaphore(int32_t count, uint16_t max_count) { constructor(count, max_count); }
ToCluster::ToCluster(QWidget *pParent, const char *name) : QWidget(pParent, name) { constructor(); _toNumber->_type = 0; }
#include <iostream> #include "app/app.hpp" #include "app/PingPong/Echo.hpp" #include "ebb/SharedRoot.hpp" #include "ebb/MessageManager/MessageManager.hpp" ebbrt::EbbRoot* ebbrt::Echo::ConstructRoot() { return new SharedRoot<Echo>; } // registers symbol for configuration __attribute__((constructor(65535))) static void _reg_symbol() { ebbrt::app::AddSymbol ("Echo", ebbrt::Echo::ConstructRoot); } ebbrt::Echo::Echo(EbbId id) : EbbRep(id) {} void ebbrt::Echo::HandleMessage(NetworkId from, Buffer buffer) { std::cout << buffer.data(); const char cbuf[] = "PONG\n"; auto buf = message_manager->Alloc(sizeof(cbuf));
ToCluster::ToCluster(int pType, QWidget *pParent) : QWidget(pParent) { constructor(); _toNumber->_type = pType; }
{ xbox->yaxis |= 0xFF; } axis_value = axis[xboxa_rstick_x]; xbox->zaxis = clamp(-128, axis_value, 127) << 8; if(axis_value > 127) { xbox->zaxis |= 0xFF; } axis_value = -axis[xboxa_rstick_y]; xbox->taxis = clamp(-128, axis_value, 127) << 8; if(axis_value > 127) { xbox->taxis |= 0xFF; } return index; } void xbox_init(void) __attribute__((constructor (101))); void xbox_init(void) { controller_register_axis_names(C_TYPE_XBOX_PAD, sizeof(axis_names)/sizeof(*axis_names), axis_names); controller_register_params(C_TYPE_XBOX_PAD, &xbox_params); control_register_names(C_TYPE_XBOX_PAD, xbox_axis_name); report_register_builder(C_TYPE_XBOX_PAD, xbox_report_build); }
if (i != 0) { fprintf(stderr, "sigprocmask: %s\n", strerror(i)); exit(EXIT_FAILURE); } // Don't try this at home. longjmp(jmp, signo); // We should never get here. abort(); } // Set up the signal handlers in a high priority constructor, // so that they are installed before the Go code starts. static void init(void) __attribute__ ((constructor (200))); static void init() { struct sigaction sa; memset(&sa, 0, sizeof sa); sa.sa_sigaction = ioHandler; if (sigemptyset(&sa.sa_mask) < 0) { die("sigemptyset"); } sa.sa_flags = SA_SIGINFO; if (sigaction(SIGIO, &sa, NULL) < 0) { die("sigaction"); } sa.sa_sigaction = segvHandler;
void pSeparator::orphan() { destructor(); constructor(); }
void pLineEdit::orphan() { destructor(); constructor(); }
/** Copy constructor. * Creates a colormap in shared memory for the given LUT ID and copies the data of the * given existing colormap. * @param cm color mape to copy from */ YuvColormap::YuvColormap(const YuvColormap &cm) { constructor(cm.depth(), cm.width(), cm.height()); memcpy(lut_, cm.lut_, lut_size_); }
Expr* const get(mpz_class index) { if (index == 0) { return constructor(); } throw std::out_of_range(""); }