summaryrefslogtreecommitdiffhomepage
path: root/src/arch/nt32/crt_tls.c
blob: b79fd5fb96f92628b5f5c2196f860ded1da95ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**************************************************************************/
/*  mmglue: midipix architecture- and target-specific bits for musl libc  */
/*  Copyright (C) 2013--2023  SysDeer Technologies, LLC                   */
/*  Released under GPLv2 and GPLv3; see COPYING.MMGLUE.                   */
/**************************************************************************/

#include <unistd.h>
#include <stdint.h>
#include <stddef.h>
#include "psxglue.h"
#include "pthread_arch.h"

typedef unsigned int __tls_word	__attribute__((mode(word)));
typedef unsigned int __tls_ptr	__attribute__((mode(pointer)));

struct __emutls_object
{
	__tls_word	size;
	__tls_word	align;
	ptrdiff_t	offset;
	void *		defval;
};

void * __emutls_get_address (struct __emutls_object * obj)
{
	int dsoidx = obj->align & 0xFFFF0000;
	struct __tlca_abi * tlca = (struct __tlca_abi *)__psx_tlca();
	return tlca->pthread_dtls[dsoidx >> 16] + obj->offset;
}