コード例 #1
0
ファイル: pwd_query.c プロジェクト: yunxiaoxiao110/haiku
void __init_pwd_backend(void)
{
    /* dev_t for the boot volume */
    boot_device = dev_for_path("/boot");
    /* get us an id for holding thread-specific data */
    pw_tls_id = tls_allocate();
}
コード例 #2
0
ファイル: Debug.cpp プロジェクト: Sylvain78/haiku
/*! \brief Returns the thread local storage handle used to store
	indentation information, allocating the handle first if
	necessary.
*/
int32
get_tls_handle()
{
	// Init the tls handle if this is the first call.
	if (!tls_handle_initialized) {
		if (atomic_or(&tls_spinlock, 1) == 0) {
			// First one in gets to init
			tls_handle = tls_allocate();	
			tls_handle_initialized = true;
			atomic_and(&tls_spinlock, 0);
		} else {
			// All others must wait patiently
			while (!tls_handle_initialized) {
				snooze(1);
			}
		}
	}
	return tls_handle;
}
コード例 #3
0
ファイル: TSRM.c プロジェクト: kennyb/php-broken
/* Startup TSRM (call once for the entire process) */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
{
#if defined(GNUPTH)
	pth_init();
#elif defined(PTHREADS)
	pthread_key_create( &tls_key, 0 );
#elif defined(TSRM_ST)
	st_init();
	st_key_create(&tls_key, 0);
#elif defined(TSRM_WIN32)
	tls_key = TlsAlloc();
#elif defined(BETHREADS)
	tls_key = tls_allocate();
#endif

	tsrm_error_file = stderr;
	tsrm_error_set(debug_level, debug_filename);
	tsrm_tls_table_size = expected_threads;

	tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
	if (!tsrm_tls_table) {
		TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate TLS table"));
		return 0;
	}
	id_count=0;

	resource_types_table_size = expected_resources;
	resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
	if (!resource_types_table) {
		TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate resource types table"));
		free(tsrm_tls_table);
		tsrm_tls_table = NULL;
		return 0;
	}

	tsmm_mutex = tsrm_mutex_alloc();

	tsrm_new_thread_begin_handler = tsrm_new_thread_end_handler = NULL;

	TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Started up TSRM, %d expected threads, %d expected resources", expected_threads, expected_resources));
	return 1;
}
コード例 #4
0
ファイル: glthread.c プロジェクト: astrofimov/vgallium
void
_glthread_InitTSD(_glthread_TSD *tsd)
{
   tsd->key = tls_allocate();
   tsd->initMagic = INIT_MAGIC;
}
コード例 #5
0
ファイル: r5_compatibility.cpp プロジェクト: mmanley/Antares
extern "C" {
	int *_h_errnop(void);
	int _netstat(int fd, char **output, int verbose);
	int _socket_interrupt(void);
	int closesocket(int socket);
	char *find_net_setting(net_settings* settings, const char* heading,
		const char* name, char* value, unsigned numBytes);
	status_t set_net_setting(net_settings* settings, const char* heading,
		const char* name, const char* value);
	int getusername(char *user, size_t bufferLength);
	int getpassword(char *password, size_t bufferLength);
	char *_netconfig_find(const char *heaading, const char *name, char *value, int nbytes);
}


int32 __gHErrnoTLS = tls_allocate();


int *
_h_errnop(void)
{
	return (int *)tls_address(__gHErrnoTLS);
}


int
_netstat(int fd, char **output, int verbose)
{
	return ENOSYS;
}
コード例 #6
0
ファイル: u_thread.c プロジェクト: digdugg/chromium.src
void
u_tsd_init(struct u_tsd *tsd)
{
    tsd->key = tls_allocate();
    tsd->initMagic = INIT_MAGIC;
}