Changeset 5312:27ec111dc8c5 in roaraudio for libroar


Ignore:
Timestamp:
11/30/11 01:05:41 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support for seperate contextes for roardl/plugins. Currently incudes error state and a global per handle data segment. This does not work for statically linked librarys (yet). support for per-context notify core needs to be added/completed.

Location:
libroar
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libroar/error.c

    r5295 r5312  
    866866} 
    867867 
     868// Resets the stored state to 'no error' state. This can be used 
     869// to init the state. 
     870int    roar_err_initstore(struct roar_error_state * state) { 
     871 struct roar_error_state curstate; 
     872 
     873 if ( state == NULL ) { 
     874  roar_err_set(ROAR_ERROR_FAULT); 
     875  return -1; 
     876 } 
     877 
     878 roar_err_store(&curstate); 
     879 roar_err_clear_all(); 
     880 roar_err_store(state); 
     881 roar_err_restore(&curstate); 
     882 
     883 return -1; 
     884} 
    868885 
    869886// store a error state (both libroar and system) 
  • libroar/roardl.c

    r5275 r5312  
    4343 struct roar_dl_librarypara * para; 
    4444 struct roar_dl_libraryinst * lib; 
     45 struct { 
     46  struct roar_error_state error_state; 
     47  void *  global_data; 
     48  void *  global_data_state; 
     49 } context; 
    4550#if defined(ROAR_HAVE_LIBDL) 
    4651 void * handle; 
     
    187192 memset(ret, 0, sizeof(struct roar_dl_lhandle)); 
    188193 
     194 roar_err_initstore(&(ret->context.error_state)); 
     195 
    189196#if defined(ROAR_HAVE_LIBDL) 
    190197 flags  = RTLD_NOW; 
     
    243250 ret = -1; 
    244251#endif 
     252 
     253 if ( lhandle->context.global_data != NULL ) 
     254  roar_mm_free(lhandle->context.global_data); 
    245255 
    246256 if ( lhandle->para != NULL ) 
     
    273283 struct roar_dl_libraryinst * (*func)(struct roar_dl_librarypara * para); 
    274284 struct roar_dl_libraryinst * lib; 
     285 void * global_data_state = NULL; 
    275286 int i; 
    276287 
     
    310321 if ( !((void*)lhandle < (void*)128) ) { 
    311322  lhandle->lib = lib; 
     323 
     324  if ( lib->global_data_len ) { 
     325   lhandle->context.global_data = roar_mm_malloc(lib->global_data_len); 
     326   if ( lhandle->context.global_data == NULL ) 
     327    return -1; 
     328 
     329   if ( lib->global_data_init == NULL ) { 
     330    memset(lhandle->context.global_data, 0, lib->global_data_len); 
     331   } else { 
     332    memcpy(lhandle->context.global_data, lib->global_data_init, lib->global_data_len); 
     333   } 
     334  } 
     335 } 
     336 
     337 if ( lib->global_data_pointer != NULL ) { 
     338  global_data_state = *(lib->global_data_pointer); 
     339  if ( !((void*)lhandle < (void*)128) ) { 
     340   *(lib->global_data_pointer) = lib->global_data_init; 
     341  } else { 
     342   *(lib->global_data_pointer) = lhandle->context.global_data; 
     343  } 
    312344 } 
    313345 
     
    315347  if ( lib->func[i] != NULL ) 
    316348   lib->func[i](para, lib); 
     349 } 
     350 
     351 if ( lib->global_data_pointer != NULL ) { 
     352  *(lib->global_data_pointer) = global_data_state; 
    317353 } 
    318354 
     
    375411} 
    376412 
     413int                      roar_dl_context_restore(struct roar_dl_lhandle * lhandle) { 
     414 struct roar_error_state error_state; 
     415 
     416 if ( (void*)lhandle < (void*)128 ) { 
     417  roar_err_set(ROAR_ERROR_NOTSUP); 
     418  return -1; 
     419 } 
     420 
     421 roar_err_store(&error_state); 
     422 roar_err_restore(&(lhandle->context.error_state)); 
     423 lhandle->context.error_state = error_state; 
     424 
     425 if ( lhandle->lib->global_data_pointer != NULL ) { 
     426  lhandle->context.global_data_state = *(lhandle->lib->global_data_pointer); 
     427  *(lhandle->lib->global_data_pointer) = lhandle->context.global_data; 
     428 } 
     429 
     430 return 0; 
     431} 
     432 
     433int                      roar_dl_context_store(struct roar_dl_lhandle * lhandle) { 
     434 struct roar_error_state error_state; 
     435 
     436 if ( (void*)lhandle < (void*)128 ) { 
     437  roar_err_set(ROAR_ERROR_NOTSUP); 
     438  return -1; 
     439 } 
     440 
     441 if ( lhandle->lib->global_data_pointer != NULL ) { 
     442  *(lhandle->lib->global_data_pointer) = lhandle->context.global_data_state; 
     443 } 
     444 
     445 roar_err_store(&error_state); 
     446 roar_err_restore(&(lhandle->context.error_state)); 
     447 lhandle->context.error_state = error_state; 
     448 
     449 return 0; 
     450} 
     451 
    377452//ll 
Note: See TracChangeset for help on using the changeset viewer.