diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 14:46:46 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-09 14:46:46 +0000 |
commit | c83ea137d7e717f764e2f31fc2544f522de7d857 (patch) | |
tree | ccfdacfdcdc4ed68e56324a07b6f25ab5327bdcd /Python/dynload_beos.c | |
parent | 368ede83d9c96004dc5c489511936a588537f410 (diff) | |
download | cpython-git-c83ea137d7e717f764e2f31fc2544f522de7d857.tar.gz |
Untabify C files. Will watch buildbots.
Diffstat (limited to 'Python/dynload_beos.c')
-rw-r--r-- | Python/dynload_beos.c | 302 |
1 files changed, 151 insertions, 151 deletions
diff --git a/Python/dynload_beos.c b/Python/dynload_beos.c index 5b05d6b733..f5ca1ec3aa 100644 --- a/Python/dynload_beos.c +++ b/Python/dynload_beos.c @@ -9,9 +9,9 @@ #include "importdl.h" const struct filedescr _PyImport_DynLoadFiletab[] = { - {".so", "rb", C_EXTENSION}, - {"module.so", "rb", C_EXTENSION}, - {0, 0} + {".so", "rb", C_EXTENSION}, + {"module.so", "rb", C_EXTENSION}, + {0, 0} }; #if defined(MAXPATHLEN) && !defined(_SYS_PARAM_H) @@ -52,13 +52,13 @@ static PyObject *beos_dyn_images = NULL; */ static void beos_nuke_dyn( PyObject *item ) { - status_t retval; + status_t retval; - if( item ) { - image_id id = (image_id)PyInt_AsLong( item ); - - retval = unload_add_on( id ); - } + if( item ) { + image_id id = (image_id)PyInt_AsLong( item ); + + retval = unload_add_on( id ); + } } /* atexit() handler that'll call unload_add_on() for every item in the @@ -66,31 +66,31 @@ static void beos_nuke_dyn( PyObject *item ) */ static void beos_cleanup_dyn( void ) { - if( beos_dyn_images ) { - int idx; - int list_size; - PyObject *id_list; + if( beos_dyn_images ) { + int idx; + int list_size; + PyObject *id_list; #ifdef WITH_THREAD - PyThread_acquire_lock( beos_dyn_lock, 1 ); + PyThread_acquire_lock( beos_dyn_lock, 1 ); #endif - id_list = PyDict_Values( beos_dyn_images ); + id_list = PyDict_Values( beos_dyn_images ); + + list_size = PyList_Size( id_list ); + for( idx = 0; idx < list_size; idx++ ) { + PyObject *the_item; - list_size = PyList_Size( id_list ); - for( idx = 0; idx < list_size; idx++ ) { - PyObject *the_item; - - the_item = PyList_GetItem( id_list, idx ); - beos_nuke_dyn( the_item ); - } + the_item = PyList_GetItem( id_list, idx ); + beos_nuke_dyn( the_item ); + } - PyDict_Clear( beos_dyn_images ); + PyDict_Clear( beos_dyn_images ); #ifdef WITH_THREAD - PyThread_free_lock( beos_dyn_lock ); + PyThread_free_lock( beos_dyn_lock ); #endif - } + } } /* @@ -98,20 +98,20 @@ static void beos_cleanup_dyn( void ) */ static void beos_init_dyn( void ) { - /* We're protected from a race condition here by the atomic init_count - * variable. - */ - static int32 init_count = 0; - int32 val; - - val = atomic_add( &init_count, 1 ); - if( beos_dyn_images == NULL && val == 0 ) { - beos_dyn_images = PyDict_New(); + /* We're protected from a race condition here by the atomic init_count + * variable. + */ + static int32 init_count = 0; + int32 val; + + val = atomic_add( &init_count, 1 ); + if( beos_dyn_images == NULL && val == 0 ) { + beos_dyn_images = PyDict_New(); #ifdef WITH_THREAD - beos_dyn_lock = PyThread_allocate_lock(); + beos_dyn_lock = PyThread_allocate_lock(); #endif - atexit( beos_cleanup_dyn ); - } + atexit( beos_cleanup_dyn ); + } } /* @@ -122,133 +122,133 @@ static void beos_init_dyn( void ) */ static void beos_add_dyn( char *name, image_id id ) { - int retval; - PyObject *py_id; + int retval; + PyObject *py_id; - if( beos_dyn_images == NULL ) { - beos_init_dyn(); - } + if( beos_dyn_images == NULL ) { + beos_init_dyn(); + } #ifdef WITH_THREAD - retval = PyThread_acquire_lock( beos_dyn_lock, 1 ); + retval = PyThread_acquire_lock( beos_dyn_lock, 1 ); #endif - /* If there's already an object with this key in the dictionary, - * we're doing a reload(), so let's nuke it. - */ - py_id = PyDict_GetItemString( beos_dyn_images, name ); - if( py_id ) { - beos_nuke_dyn( py_id ); - retval = PyDict_DelItemString( beos_dyn_images, name ); - } + /* If there's already an object with this key in the dictionary, + * we're doing a reload(), so let's nuke it. + */ + py_id = PyDict_GetItemString( beos_dyn_images, name ); + if( py_id ) { + beos_nuke_dyn( py_id ); + retval = PyDict_DelItemString( beos_dyn_images, name ); + } - py_id = PyInt_FromLong( (long)id ); - if( py_id ) { - retval = PyDict_SetItemString( beos_dyn_images, name, py_id ); - } + py_id = PyInt_FromLong( (long)id ); + if( py_id ) { + retval = PyDict_SetItemString( beos_dyn_images, name, py_id ); + } #ifdef WITH_THREAD - PyThread_release_lock( beos_dyn_lock ); + PyThread_release_lock( beos_dyn_lock ); #endif } dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, - const char *pathname, FILE *fp) + const char *pathname, FILE *fp) { - dl_funcptr p; - image_id the_id; - status_t retval; - char fullpath[PATH_MAX]; - char funcname[258]; - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s )\n", pathname ); - } - - /* Hmm, this old bug appears to have regenerated itself; if the - * path isn't absolute, load_add_on() will fail. Reported to Be - * April 21, 1998. - */ - if( pathname[0] != '/' ) { - (void)getcwd( fullpath, PATH_MAX ); - (void)strncat( fullpath, "/", PATH_MAX ); - (void)strncat( fullpath, pathname, PATH_MAX ); - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s )\n", fullpath ); - } - } else { - (void)strcpy( fullpath, pathname ); - } - - the_id = load_add_on( fullpath ); - if( the_id < B_NO_ERROR ) { - /* It's too bad load_add_on() doesn't set errno or something... - */ - char buff[256]; /* hate hard-coded string sizes... */ - - if( Py_VerboseFlag ) { - printf( "load_add_on( %s ) failed", fullpath ); - } - - if( the_id == B_ERROR ) - PyOS_snprintf( buff, sizeof(buff), - "BeOS: Failed to load %.200s", - fullpath ); - else - PyOS_snprintf( buff, sizeof(buff), - "Unknown error loading %.200s", - fullpath ); - - PyErr_SetString( PyExc_ImportError, buff ); - return NULL; - } - - PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - if( Py_VerboseFlag ) { - printf( "get_image_symbol( %s )\n", funcname ); - } - - retval = get_image_symbol( the_id, funcname, B_SYMBOL_TYPE_TEXT, &p ); - if( retval != B_NO_ERROR || p == NULL ) { - /* That's bad, we can't find that symbol in the module... - */ - char buff[256]; /* hate hard-coded string sizes... */ - - if( Py_VerboseFlag ) { - printf( "get_image_symbol( %s ) failed", funcname ); - } - - switch( retval ) { - case B_BAD_IMAGE_ID: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Invalid image ID for %.180s", fullpath ); - break; - case B_BAD_INDEX: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Bad index for %.180s", funcname ); - break; - default: - PyOS_snprintf( buff, sizeof(buff), - "can't load init function for dynamic module: " - "Unknown error looking up %.180s", funcname ); - break; - } - - retval = unload_add_on( the_id ); - - PyErr_SetString( PyExc_ImportError, buff ); - return NULL; - } - - /* Save the module name and image ID for later so we can clean up - * gracefully. - */ - beos_add_dyn( fqname, the_id ); - - return p; + dl_funcptr p; + image_id the_id; + status_t retval; + char fullpath[PATH_MAX]; + char funcname[258]; + + if( Py_VerboseFlag ) { + printf( "load_add_on( %s )\n", pathname ); + } + + /* Hmm, this old bug appears to have regenerated itself; if the + * path isn't absolute, load_add_on() will fail. Reported to Be + * April 21, 1998. + */ + if( pathname[0] != '/' ) { + (void)getcwd( fullpath, PATH_MAX ); + (void)strncat( fullpath, "/", PATH_MAX ); + (void)strncat( fullpath, pathname, PATH_MAX ); + + if( Py_VerboseFlag ) { + printf( "load_add_on( %s )\n", fullpath ); + } + } else { + (void)strcpy( fullpath, pathname ); + } + + the_id = load_add_on( fullpath ); + if( the_id < B_NO_ERROR ) { + /* It's too bad load_add_on() doesn't set errno or something... + */ + char buff[256]; /* hate hard-coded string sizes... */ + + if( Py_VerboseFlag ) { + printf( "load_add_on( %s ) failed", fullpath ); + } + + if( the_id == B_ERROR ) + PyOS_snprintf( buff, sizeof(buff), + "BeOS: Failed to load %.200s", + fullpath ); + else + PyOS_snprintf( buff, sizeof(buff), + "Unknown error loading %.200s", + fullpath ); + + PyErr_SetString( PyExc_ImportError, buff ); + return NULL; + } + + PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); + if( Py_VerboseFlag ) { + printf( "get_image_symbol( %s )\n", funcname ); + } + + retval = get_image_symbol( the_id, funcname, B_SYMBOL_TYPE_TEXT, &p ); + if( retval != B_NO_ERROR || p == NULL ) { + /* That's bad, we can't find that symbol in the module... + */ + char buff[256]; /* hate hard-coded string sizes... */ + + if( Py_VerboseFlag ) { + printf( "get_image_symbol( %s ) failed", funcname ); + } + + switch( retval ) { + case B_BAD_IMAGE_ID: + PyOS_snprintf( buff, sizeof(buff), + "can't load init function for dynamic module: " + "Invalid image ID for %.180s", fullpath ); + break; + case B_BAD_INDEX: + PyOS_snprintf( buff, sizeof(buff), + "can't load init function for dynamic module: " + "Bad index for %.180s", funcname ); + break; + default: + PyOS_snprintf( buff, sizeof(buff), + "can't load init function for dynamic module: " + "Unknown error looking up %.180s", funcname ); + break; + } + + retval = unload_add_on( the_id ); + + PyErr_SetString( PyExc_ImportError, buff ); + return NULL; + } + + /* Save the module name and image ID for later so we can clean up + * gracefully. + */ + beos_add_dyn( fqname, the_id ); + + return p; } |