mirror of
https://github.com/rtlduino/RTL8710AF_GCC.git
synced 2025-07-31 20:21:04 +00:00
motify compile link error
motify compile link error
This commit is contained in:
parent
923914edae
commit
03e74a8e50
5418 changed files with 1367914 additions and 206149 deletions
675
component/common/application/jd_joinlink/example_joinlink.c
Normal file
675
component/common/application/jd_joinlink/example_joinlink.c
Normal file
|
|
@ -0,0 +1,675 @@
|
||||||
|
/*******************************example_joinlink **************************/
|
||||||
|
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "platform_stdlib.h"
|
||||||
|
#include "wifi_conf.h"
|
||||||
|
#include "wifi_structures.h"
|
||||||
|
#include "osdep_service.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "joinlink.h"
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
#include <lwip/raw.h>
|
||||||
|
#include <lwip/icmp.h>
|
||||||
|
#include <lwip/inet_chksum.h>
|
||||||
|
#include <platform/platform_stdlib.h>
|
||||||
|
|
||||||
|
#define MASK_SIZE_JOINLINK 3
|
||||||
|
#define SOURCE_PORT 101
|
||||||
|
|
||||||
|
//gloable
|
||||||
|
static unsigned char cur_channel = 1;
|
||||||
|
static unsigned char lock_channel = 1;
|
||||||
|
static _timer timer_handler_phase2;
|
||||||
|
static _timer timer_handler_phase1;
|
||||||
|
static u8 joinlink_finished = 0;
|
||||||
|
static u8 security_type = 0xff;
|
||||||
|
static u8 jl_rx_flag = 0;
|
||||||
|
static rtw_scan_result_t *all_channel_scan_result = NULL;
|
||||||
|
static rtw_scan_result_t *p_result = NULL;
|
||||||
|
static int all_channel_ret = 0;
|
||||||
|
static int phase1_finished = 0;
|
||||||
|
static int phase2_started = 0;
|
||||||
|
static u32 start_time = 0;
|
||||||
|
static u32 current_time = 0;
|
||||||
|
static int idx = 1;
|
||||||
|
static int phase1_scanned_channel[14];
|
||||||
|
static char ap_bssid[6];
|
||||||
|
static char aes_key[] = "123456789";
|
||||||
|
|
||||||
|
static void* pre_scan_sema;
|
||||||
|
static int ack_socket;
|
||||||
|
static struct sockaddr_in to_addr;
|
||||||
|
static struct sockaddr_in from_addr;
|
||||||
|
static char header_cmd[] = "cmd";
|
||||||
|
static cJSON *ack_content = NULL;
|
||||||
|
extern struct netif xnetif[];
|
||||||
|
|
||||||
|
void example_joinlink(void);
|
||||||
|
|
||||||
|
static rtw_result_t joinlink_scan_result_handler(rtw_scan_handler_result_t* malloced_scan_result )
|
||||||
|
{
|
||||||
|
|
||||||
|
static int ApNum = 0;
|
||||||
|
//TODO: add timer of 2s, wf, 1021
|
||||||
|
if (malloced_scan_result->scan_complete != RTW_TRUE) {
|
||||||
|
rtw_scan_result_t* record = &malloced_scan_result->ap_details;
|
||||||
|
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
|
||||||
|
++ApNum;
|
||||||
|
|
||||||
|
if(malloced_scan_result->user_data)
|
||||||
|
memcpy((void *)((char *)malloced_scan_result->user_data+(ApNum-1)*sizeof(rtw_scan_result_t)), (char *)record, sizeof(rtw_scan_result_t));
|
||||||
|
}
|
||||||
|
// scan finished, wf, 1022
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rtw_up_sema(&pre_scan_sema);
|
||||||
|
ApNum = 0;
|
||||||
|
}
|
||||||
|
return RTW_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* joinlink_all_scan()
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
rtw_scan_result_t *joinlink_scan_buf = NULL;
|
||||||
|
|
||||||
|
if(joinlink_scan_buf != NULL)
|
||||||
|
free(joinlink_scan_buf);
|
||||||
|
|
||||||
|
joinlink_scan_buf = (rtw_scan_result_t *)malloc(65*sizeof(rtw_scan_result_t));
|
||||||
|
if(joinlink_scan_buf == NULL){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
memset(joinlink_scan_buf, 0, 65*sizeof(rtw_scan_result_t));
|
||||||
|
|
||||||
|
if((ret = wifi_scan_networks(joinlink_scan_result_handler, joinlink_scan_buf)) != RTW_SUCCESS){
|
||||||
|
printf("[ATWS]ERROR: wifi scan failed\n\r");
|
||||||
|
free(joinlink_scan_buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return joinlink_scan_buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void joinlink_deinit_content()
|
||||||
|
{
|
||||||
|
rtw_del_timer(&timer_handler_phase2);
|
||||||
|
rtw_del_timer(&timer_handler_phase1);
|
||||||
|
if(all_channel_scan_result)
|
||||||
|
{
|
||||||
|
free(all_channel_scan_result);
|
||||||
|
all_channel_scan_result = NULL;
|
||||||
|
}
|
||||||
|
rtw_free_sema(&pre_scan_sema);
|
||||||
|
joinlink_deinit();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
static char *jl_itoa(int value)
|
||||||
|
{
|
||||||
|
char *val_str;
|
||||||
|
int tmp = value, len = 1;
|
||||||
|
|
||||||
|
while((tmp /= 10) > 0)
|
||||||
|
len ++;
|
||||||
|
|
||||||
|
val_str = (char *) malloc(len + 1);
|
||||||
|
sprintf(val_str, "%d", value);
|
||||||
|
|
||||||
|
return val_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void get_ip_str(int *ip_int, char *ip_ch)
|
||||||
|
{
|
||||||
|
char *ip_single = NULL;
|
||||||
|
u8 pos = 0, len = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
ip_single = jl_itoa(ip_int[i]);
|
||||||
|
len = strlen(ip_single);
|
||||||
|
memcpy(ip_ch + pos, ip_single,len);
|
||||||
|
free(ip_single);
|
||||||
|
ip_single = NULL;
|
||||||
|
pos += len;
|
||||||
|
if(i == 3)
|
||||||
|
{
|
||||||
|
*(ip_ch + pos) = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*(ip_ch + pos) = '.';
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int joinlink_set_ack_content(u8 check_sum)
|
||||||
|
{
|
||||||
|
cJSON_Hooks memoryHook;
|
||||||
|
memoryHook.malloc_fn = malloc;
|
||||||
|
memoryHook.free_fn = free;
|
||||||
|
cJSON_InitHooks(&memoryHook);
|
||||||
|
|
||||||
|
if(ack_content != NULL)
|
||||||
|
{
|
||||||
|
cJSON_Delete(ack_content);
|
||||||
|
ack_content = NULL;
|
||||||
|
}
|
||||||
|
if((ack_content = cJSON_CreateObject()) != NULL)
|
||||||
|
{
|
||||||
|
char mac_str[18];
|
||||||
|
u8 pos = 0;
|
||||||
|
memset(mac_str, 0, sizeof(mac_str));
|
||||||
|
for(int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
sprintf(mac_str + pos, "%02x", xnetif[0].hwaddr[i]);
|
||||||
|
pos += 2;
|
||||||
|
if(i != 5)
|
||||||
|
mac_str[pos++] = ':';
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON_AddItemToObject(ack_content, "deviceid", cJSON_CreateString(mac_str));
|
||||||
|
cJSON_AddItemToObject(ack_content, "code", cJSON_CreateNumber(check_sum));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("create jSON object failure\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
static void recv_cmd(void *para)
|
||||||
|
{
|
||||||
|
int rev_len = 0;
|
||||||
|
char pkt_buf[16];
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
vTaskDelay(500);
|
||||||
|
if((rev_len = recvfrom(ack_socket, pkt_buf, sizeof(pkt_buf), 0, NULL, NULL)) >= 0)
|
||||||
|
{
|
||||||
|
if(memcmp(pkt_buf, header_cmd, sizeof(header_cmd)) == 0)
|
||||||
|
{
|
||||||
|
printf("received reboot command, restart join_link process\n");
|
||||||
|
// do we need to reboot?
|
||||||
|
example_joinlink();
|
||||||
|
close(ack_socket);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int send_ack(int *dest_ip, int dest_port, u8 sum)
|
||||||
|
{
|
||||||
|
#if CONFIG_LWIP_LAYER
|
||||||
|
int ack_transmit_round;
|
||||||
|
char ip[16];
|
||||||
|
char *jsonString = NULL;
|
||||||
|
int sended_data = 0;
|
||||||
|
|
||||||
|
if(joinlink_set_ack_content(sum) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
jsonString = cJSON_Print(ack_content);
|
||||||
|
if(jsonString == NULL)
|
||||||
|
{
|
||||||
|
printf("json string convert failure\n");
|
||||||
|
cJSON_Delete(ack_content);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_ip_str(dest_ip, ip);
|
||||||
|
|
||||||
|
ack_socket = socket(PF_INET, SOCK_DGRAM, IP_PROTO_UDP);
|
||||||
|
if (ack_socket == -1) {
|
||||||
|
printf("create socket failure\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FD_ZERO(&to_addr);
|
||||||
|
to_addr.sin_family = AF_INET;
|
||||||
|
to_addr.sin_port = htons(dest_port);
|
||||||
|
to_addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
|
FD_ZERO(&from_addr);
|
||||||
|
from_addr.sin_family = AF_INET;
|
||||||
|
from_addr.sin_port = htons(SOURCE_PORT);
|
||||||
|
to_addr.sin_addr.s_addr = inet_addr(ip);
|
||||||
|
|
||||||
|
if(bind(ack_socket, (struct sockaddr *)&from_addr, sizeof(from_addr)) < 0)
|
||||||
|
{
|
||||||
|
printf("bind to source port error\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ack_transmit_round = 0; ack_transmit_round < 5; ack_transmit_round++) {
|
||||||
|
sended_data = sendto(ack_socket, (unsigned char *)jsonString, strlen(jsonString), 0, (struct sockaddr *) &to_addr, sizeof(struct sockaddr));
|
||||||
|
//printf("\r\nAlready send %d bytes data\n", sended_data);
|
||||||
|
vTaskDelay(100); /* delay 100 ms */
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xTaskCreate(recv_cmd, (char const *)"recv_cmd", 1512, NULL, tskIDLE_PRIORITY + 2, NULL) != pdPASS)
|
||||||
|
printf("%s xTaskCreate failed\n", __FUNCTION__);
|
||||||
|
|
||||||
|
close(ack_socket);
|
||||||
|
if(jsonString)
|
||||||
|
{
|
||||||
|
free(jsonString);
|
||||||
|
jsonString = NULL;
|
||||||
|
}
|
||||||
|
cJSON_Delete(ack_content);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
static void remove_filter()
|
||||||
|
{
|
||||||
|
wifi_disable_packet_filter(1);
|
||||||
|
wifi_disable_packet_filter(2);
|
||||||
|
wifi_remove_packet_filter(1);
|
||||||
|
wifi_remove_packet_filter(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int joinlink_finish(unsigned char security_type)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int retry = 3;
|
||||||
|
unsigned char pscan_config = 1;
|
||||||
|
joinlink_result_t result;
|
||||||
|
rtw_security_t security_mode;
|
||||||
|
|
||||||
|
wifi_set_promisc(RTW_PROMISC_DISABLE,NULL,0);
|
||||||
|
remove_filter();
|
||||||
|
|
||||||
|
pscan_config = PSCAN_ENABLE | PSCAN_SIMPLE_CONFIG;
|
||||||
|
ret = joinlink_get_result(&result);
|
||||||
|
if (ret == 0) {
|
||||||
|
printf("get result OK\n");
|
||||||
|
//printf("\r\n joinlink get result ok,ssid = %s, pwd = %s,ssid length = %d,pwd length = %d",
|
||||||
|
// result.ssid, result.pwd, result.ssid_length,result.pwd_length);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
printf("joinlink result not get!\n");
|
||||||
|
joinlink_deinit_content();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//ap security type
|
||||||
|
switch(security_type){
|
||||||
|
case RTW_ENCRYPTION_OPEN:
|
||||||
|
security_mode = RTW_SECURITY_OPEN;
|
||||||
|
break;
|
||||||
|
case RTW_ENCRYPTION_WEP40:
|
||||||
|
case RTW_ENCRYPTION_WEP104:
|
||||||
|
security_mode = RTW_SECURITY_WEP_PSK;
|
||||||
|
break;
|
||||||
|
case RTW_ENCRYPTION_WPA_TKIP:
|
||||||
|
case RTW_ENCRYPTION_WPA_AES:
|
||||||
|
case RTW_ENCRYPTION_WPA2_TKIP:
|
||||||
|
case RTW_ENCRYPTION_WPA2_AES:
|
||||||
|
case RTW_ENCRYPTION_WPA2_MIXED:
|
||||||
|
security_mode = RTW_SECURITY_WPA2_AES_PSK;
|
||||||
|
break;
|
||||||
|
case RTW_ENCRYPTION_UNKNOWN:
|
||||||
|
case RTW_ENCRYPTION_UNDEF:
|
||||||
|
default:
|
||||||
|
printf("unknow security mode,connect fail!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
while(1){
|
||||||
|
if(wifi_set_pscan_chan(&lock_channel, &pscan_config, 1) < 0){
|
||||||
|
printf("ERROR: wifi set partial scan channel fail\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("wifi_connect\n");
|
||||||
|
//printf("ap_bssid: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", ap_bssid[0],ap_bssid[1],ap_bssid[2],ap_bssid[3],ap_bssid[4],ap_bssid[5]);
|
||||||
|
|
||||||
|
|
||||||
|
ret = wifi_connect((unsigned char *)result.ssid, security_mode,
|
||||||
|
(unsigned char *)result.pwd, result.ssid_length,
|
||||||
|
result.pwd_length,
|
||||||
|
0,NULL);
|
||||||
|
|
||||||
|
if(ret == RTW_SUCCESS){
|
||||||
|
printf("Connect ok!\n");
|
||||||
|
#if CONFIG_LWIP_LAYER
|
||||||
|
/* If not rise priority, LwIP DHCP may timeout */
|
||||||
|
vTaskPrioritySet(NULL, tskIDLE_PRIORITY + 3);
|
||||||
|
/* Start DHCP Client */
|
||||||
|
ret = LwIP_DHCP(0, DHCP_START);
|
||||||
|
vTaskPrioritySet(NULL, tskIDLE_PRIORITY + 1);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (retry == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
retry--;
|
||||||
|
}
|
||||||
|
if(send_ack(result.source_ip, result.source_port, result.sum) != 0)
|
||||||
|
printf("send ack failure\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
joinlink_deinit_content();
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
// handler for phase2
|
||||||
|
void timer_handler_phase2_func(void *FunctionContext)
|
||||||
|
{
|
||||||
|
// do not switch channel while handle frames, wf, 1021
|
||||||
|
if(jl_rx_flag){
|
||||||
|
rtw_set_timer(&timer_handler_phase2, CHANNEL_SWITCH_TIME - 25);
|
||||||
|
} else {
|
||||||
|
if(cur_channel >= 13)
|
||||||
|
{cur_channel = 1;}
|
||||||
|
else
|
||||||
|
cur_channel ++;
|
||||||
|
wifi_set_channel(cur_channel);
|
||||||
|
rtw_set_timer(&timer_handler_phase2, CHANNEL_SWITCH_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("phase2:wifi switch channel to %d\n",cur_channel);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// timer handler for the 1st phase, wf, 1022
|
||||||
|
void timer_handler_phase1_func(void *FunctionContext)
|
||||||
|
{
|
||||||
|
// do not switch channel while handle frames, wf, 1021
|
||||||
|
if(jl_rx_flag){
|
||||||
|
rtw_set_timer(&timer_handler_phase1, SSID_SWITCH_TIME - 25);
|
||||||
|
}
|
||||||
|
// switch ssid, wf, 1022
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(idx >= 14)
|
||||||
|
{
|
||||||
|
phase1_finished = 1;
|
||||||
|
printf("wifi: phase1 scan finished\n");
|
||||||
|
printf("wifi: start phase2 scan\n");
|
||||||
|
// move from pkt handler to here in case no pkt to trigue phase2
|
||||||
|
#if 1
|
||||||
|
if(phase1_finished)
|
||||||
|
{
|
||||||
|
phase1_finished = 0;
|
||||||
|
phase2_started = 1;
|
||||||
|
rtw_cancel_timer(&timer_handler_phase1);
|
||||||
|
//start phase2 for ch1~ch13
|
||||||
|
cur_channel = 1;
|
||||||
|
wifi_set_channel(cur_channel);
|
||||||
|
|
||||||
|
rtw_init_timer(&timer_handler_phase2, NULL, &timer_handler_phase2_func, NULL, "phase_2");
|
||||||
|
rtw_set_timer(&timer_handler_phase2, CHANNEL_SWITCH_TIME);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(idx < 14)
|
||||||
|
{
|
||||||
|
if(phase1_scanned_channel[idx])
|
||||||
|
{
|
||||||
|
wifi_set_channel(idx);
|
||||||
|
rtw_set_timer(&timer_handler_phase1, SSID_SWITCH_TIME);
|
||||||
|
//printf("phase1: wifi switch channel to %d\n",idx);
|
||||||
|
idx++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(idx == 13)
|
||||||
|
rtw_set_timer(&timer_handler_phase1, SSID_SWITCH_TIME);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rtl_frame_recv_handle(unsigned char *buf, int len, unsigned char *da, unsigned char *sa, void *user_data) {
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
int fixed_channel;
|
||||||
|
char scanned_ssid[50] = {0};
|
||||||
|
unsigned char *current_bssid = NULL;
|
||||||
|
int scanned_ssid_len = 0;
|
||||||
|
|
||||||
|
//set this flag prevent joinlink_recv interruptted by timer,since timer has higher priority
|
||||||
|
jl_rx_flag = 1;
|
||||||
|
if (joinlink_finished) {
|
||||||
|
jl_rx_flag = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = joinlink_recv(da, sa, len, user_data);
|
||||||
|
if(ret == JOINLINK_STATUS_CHANNEL_LOCKED)
|
||||||
|
{
|
||||||
|
if(phase2_started)
|
||||||
|
{
|
||||||
|
phase2_started = 0;
|
||||||
|
rtw_cancel_timer(&timer_handler_phase2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rtw_cancel_timer(&timer_handler_phase1);
|
||||||
|
|
||||||
|
lock_channel = cur_channel;
|
||||||
|
security_type = ((ieee80211_frame_info_t *)user_data)->encrypt;
|
||||||
|
printf("JoinLink locked to channel[%d]\n",lock_channel);
|
||||||
|
|
||||||
|
current_bssid = buf + 4 + ETH_ALEN;
|
||||||
|
memcpy(ap_bssid, current_bssid, 6);
|
||||||
|
|
||||||
|
fixed_channel = promisc_get_fixed_channel(current_bssid, scanned_ssid, &scanned_ssid_len);
|
||||||
|
if (fixed_channel != 0) {
|
||||||
|
printf("JoinLink force fixed to channel[%d]\r\n",fixed_channel);
|
||||||
|
printf("JoinLink ssid scanned[%s]\r\n",scanned_ssid);
|
||||||
|
wifi_set_channel(fixed_channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(ret == JOINLINK_STATUS_COMPLETE){
|
||||||
|
//wifi_set_promisc(RTW_PROMISC_DISABLE,NULL,0);
|
||||||
|
joinlink_finished = 1;
|
||||||
|
printf("quit promisc mode!\r\n");
|
||||||
|
}
|
||||||
|
//release flag
|
||||||
|
jl_rx_flag = 0;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// callback for promisc packets, like rtk_start_parse_packet in SC, wf, 1021
|
||||||
|
void wifi_promisc_rx(unsigned char* buf, unsigned int len, void* user_data)
|
||||||
|
{
|
||||||
|
unsigned char * da = buf;
|
||||||
|
unsigned char * sa = buf + ETH_ALEN;
|
||||||
|
|
||||||
|
if (joinlink_finished)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rtl_frame_recv_handle(buf, len, da, sa, user_data);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// the entry point for joinlink
|
||||||
|
void joinlink_process(void *param)
|
||||||
|
{
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
current_time = xTaskGetTickCount();
|
||||||
|
|
||||||
|
if(joinlink_finished)
|
||||||
|
{
|
||||||
|
printf("joinlink finished\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((current_time - start_time) > JOINLINK_TIME * configTICK_RATE_HZ)
|
||||||
|
{
|
||||||
|
printf("joinlink timeout\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelay(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
joinlink_finish(security_type);
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int joinlink_init_content()
|
||||||
|
{
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
ret = joinlink_init();
|
||||||
|
if(ret < 0){
|
||||||
|
printf("JoinLink init failed!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
memset(phase1_scanned_channel, 0, sizeof(phase1_scanned_channel));
|
||||||
|
security_type = 0xff;
|
||||||
|
cur_channel = 1;
|
||||||
|
lock_channel = 1;
|
||||||
|
joinlink_finished = 0;
|
||||||
|
jl_rx_flag = 0;
|
||||||
|
p_result = NULL;
|
||||||
|
all_channel_ret = 0;
|
||||||
|
phase1_finished = 0;
|
||||||
|
phase2_started = 0;
|
||||||
|
idx = 1;
|
||||||
|
rtw_init_sema(&pre_scan_sema, 0);
|
||||||
|
memset(ap_bssid, 0, sizeof(ap_bssid));
|
||||||
|
set_aes_key(aes_key, sizeof(aes_key) - 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ret:1 indicate suc, else fail
|
||||||
|
int scan_all_channel()
|
||||||
|
{
|
||||||
|
all_channel_scan_result = (rtw_scan_result_t *)joinlink_all_scan();
|
||||||
|
|
||||||
|
if(all_channel_scan_result == NULL)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_phase1_channel()
|
||||||
|
{
|
||||||
|
p_result = all_channel_scan_result;
|
||||||
|
while(p_result->channel)
|
||||||
|
{
|
||||||
|
if((p_result->channel >= 1) && (p_result->channel <= 13))
|
||||||
|
phase1_scanned_channel[p_result->channel] = 1;
|
||||||
|
p_result++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now only accept mcast and bcast pkt
|
||||||
|
static void filter_add_enable()
|
||||||
|
{
|
||||||
|
u8 mask[MASK_SIZE_JOINLINK]={0xFF,0xFF,0xFF};
|
||||||
|
u8 pattern[MASK_SIZE_JOINLINK]={0x01,0x00,0x5e};
|
||||||
|
u8 pattern_bcast[MASK_SIZE_JOINLINK]={0xff,0xff,0xff};
|
||||||
|
|
||||||
|
rtw_packet_filter_pattern_t packet_filter;
|
||||||
|
rtw_packet_filter_pattern_t packet_filter_bcast;
|
||||||
|
rtw_packet_filter_rule_e rule;
|
||||||
|
|
||||||
|
packet_filter.offset = 0;
|
||||||
|
packet_filter.mask_size = 3;
|
||||||
|
packet_filter.mask = mask;
|
||||||
|
packet_filter.pattern = pattern;
|
||||||
|
|
||||||
|
packet_filter_bcast.offset = 0;
|
||||||
|
packet_filter_bcast.mask_size = 3;
|
||||||
|
packet_filter_bcast.mask = mask;
|
||||||
|
packet_filter_bcast.pattern = pattern_bcast;
|
||||||
|
|
||||||
|
rule = RTW_POSITIVE_MATCHING;
|
||||||
|
|
||||||
|
wifi_init_packet_filter();
|
||||||
|
wifi_add_packet_filter(1, &packet_filter,rule);
|
||||||
|
wifi_add_packet_filter(2, &packet_filter_bcast,rule);
|
||||||
|
|
||||||
|
wifi_enable_packet_filter(1);
|
||||||
|
wifi_enable_packet_filter(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void joinlink_start(void *param)
|
||||||
|
{
|
||||||
|
joinlink_finished = 0;
|
||||||
|
start_time = xTaskGetTickCount();
|
||||||
|
|
||||||
|
if(xTaskCreate(joinlink_process, (char const *)"JoinLink", 1512, NULL, tskIDLE_PRIORITY + 2, NULL) != pdPASS)
|
||||||
|
printf("%s xTaskCreate failed\n", __FUNCTION__);
|
||||||
|
|
||||||
|
if (joinlink_init_content() < 0)
|
||||||
|
printf("joinlink init fail!\n");
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(wifi_is_ready_to_transceive(RTW_STA_INTERFACE) == RTW_SUCCESS)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
vTaskDelay(3000);
|
||||||
|
}
|
||||||
|
all_channel_ret = scan_all_channel();
|
||||||
|
|
||||||
|
if (rtw_down_sema(&pre_scan_sema) == _FAIL)
|
||||||
|
printf("%s, Take Semaphore Fail\n", __FUNCTION__);
|
||||||
|
|
||||||
|
//printf("\npre scan finished\n");
|
||||||
|
|
||||||
|
//set wifi to station mode,enable promisc mode and timer to change channel
|
||||||
|
wifi_enter_promisc_mode();
|
||||||
|
filter_add_enable();
|
||||||
|
|
||||||
|
/* enable all 802.11 packets*/
|
||||||
|
wifi_set_promisc(RTW_PROMISC_ENABLE, wifi_promisc_rx, 1);
|
||||||
|
|
||||||
|
//init timer handler,and set timer hanler funcion
|
||||||
|
if(all_channel_ret)
|
||||||
|
{
|
||||||
|
printf("\nstart the phase1 scan\n");
|
||||||
|
get_phase1_channel();
|
||||||
|
rtw_init_timer(&timer_handler_phase1, NULL, &timer_handler_phase1_func, NULL, "phase1_timer");
|
||||||
|
rtw_set_timer(&timer_handler_phase1, SSID_SWITCH_TIME);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("phase1 scan fail, start phase2 scan\n");
|
||||||
|
rtw_init_timer(&timer_handler_phase2, NULL, &timer_handler_phase2_func, NULL, "phase2_timer");
|
||||||
|
wifi_set_channel(cur_channel);
|
||||||
|
rtw_set_timer(&timer_handler_phase2, CHANNEL_SWITCH_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void example_joinlink(void)
|
||||||
|
{
|
||||||
|
if(xTaskCreate(joinlink_start, (char const *)"JoinLink_entry", 1512, NULL, tskIDLE_PRIORITY + 2, NULL) != pdPASS)
|
||||||
|
printf("%s xTaskCreate failed\n", __FUNCTION__);
|
||||||
|
}
|
||||||
1100
component/common/application/jd_joinlink/joinlink.c
Normal file
1100
component/common/application/jd_joinlink/joinlink.c
Normal file
File diff suppressed because it is too large
Load diff
64
component/common/application/jd_joinlink/joinlink.h
Normal file
64
component/common/application/jd_joinlink/joinlink.h
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
/******************************* joinlink **************************/
|
||||||
|
#ifndef __JOINLINK_H
|
||||||
|
#define __JOINLINK_H
|
||||||
|
|
||||||
|
#include "autoconf.h"
|
||||||
|
#include "platform_stdlib.h"
|
||||||
|
#include "wifi_conf.h"
|
||||||
|
#include "wifi_structures.h"
|
||||||
|
#include "osdep_service.h"
|
||||||
|
#include "lwip_netconf.h"
|
||||||
|
#include "task.h"
|
||||||
|
#include "hal_crypto.h"
|
||||||
|
|
||||||
|
#define SSID_SWITCH_TIME 500 //ssid switch time in phase1,units:ms, 50
|
||||||
|
#define CHANNEL_SWITCH_TIME 500 //channel switch time in phase2,units:ms, 50
|
||||||
|
#define JOINLINK_TIME 120 //timeout for joinlink process, units: s
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store AP profile after successfully decode
|
||||||
|
* SUM +£¨length£¬pass£©+£¨IP+Port£©+£¨length£¬SSID)
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned char sum;
|
||||||
|
unsigned char pwd_length;
|
||||||
|
char pwd[65];
|
||||||
|
int source_ip[4];
|
||||||
|
unsigned int source_port;
|
||||||
|
unsigned char ssid_length;
|
||||||
|
char ssid[65];
|
||||||
|
} joinlink_result_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return value of joinlink_recv()
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
JOINLINK_STATUS_CONTINUE = 0,
|
||||||
|
JOINLINK_STATUS_CHANNEL_LOCKED = 1,
|
||||||
|
JOINLINK_STATUS_COMPLETE = 2
|
||||||
|
} joinlink_status_t;
|
||||||
|
|
||||||
|
//initialize the related data structure
|
||||||
|
int joinlink_init();
|
||||||
|
/*
|
||||||
|
handler to decode pkt
|
||||||
|
*/
|
||||||
|
joinlink_status_t joinlink_recv(unsigned char *da, unsigned char *sa, int len, void *user_data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get the AP profile after decode
|
||||||
|
*/
|
||||||
|
int joinlink_get_result(joinlink_result_t *result);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set the aes_key, the max len should be 16
|
||||||
|
* ret 1: success; ret 0: the len is invalid;
|
||||||
|
*/
|
||||||
|
int set_aes_key(char *key, int len);
|
||||||
|
|
||||||
|
// call this after finish join_link process
|
||||||
|
void joinlink_deinit();
|
||||||
|
|
||||||
|
#endif //__JOINLINK_H
|
||||||
BIN
doc/UM0023 Realtek Ameba-1 build environment setup - iar.pdf
Normal file
BIN
doc/UM0023 Realtek Ameba-1 build environment setup - iar.pdf
Normal file
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
||||||
#define UTS_VERSION "2016/09/02-11:19:15"
|
#define UTS_VERSION "2016/09/18-08:50:19"
|
||||||
#define RTL8195AFW_COMPILE_TIME "2016/09/02-11:19:15"
|
#define RTL8195AFW_COMPILE_TIME "2016/09/18-08:50:19"
|
||||||
#define RTL8195AFW_COMPILE_DATE "20160902"
|
#define RTL8195AFW_COMPILE_DATE "20160918"
|
||||||
#define RTL8195AFW_COMPILE_BY "jimmysqf"
|
#define RTL8195AFW_COMPILE_BY "root"
|
||||||
#define RTL8195AFW_COMPILE_HOST ""
|
#define RTL8195AFW_COMPILE_HOST ""
|
||||||
#define RTL8195AFW_COMPILE_DOMAIN "realtek-sg.com"
|
#define RTL8195AFW_COMPILE_DOMAIN ""
|
||||||
#define RTL195AFW_COMPILER "gcc 4.8.3"
|
#define RTL195AFW_COMPILER "gcc 4.8.3"
|
||||||
|
|
|
||||||
6
tools/DownloadServer/readme.txt
Normal file
6
tools/DownloadServer/readme.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
The exe file is used to send image to device based on socket by OTA function.
|
||||||
|
|
||||||
|
Command :
|
||||||
|
DownloadServer "PORT" "FILE_PATH"
|
||||||
|
|
||||||
|
You can edit start.bat to change port and file path.
|
||||||
3
tools/DownloadServer/start.bat
Normal file
3
tools/DownloadServer/start.bat
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
@echo off
|
||||||
|
DownloadServer 8082 ota.bin
|
||||||
|
set /p DUMMY=Press Enter to Continue ...
|
||||||
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ar
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ar
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/as
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/as
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/c++
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/c++
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/g++
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/g++
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/gcc
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/gcc
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ld
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ld
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ld.bfd
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ld.bfd
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/nm
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/nm
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/objcopy
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/objcopy
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/objdump
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/objdump
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ranlib
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/ranlib
Normal file
Binary file not shown.
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/strip
Normal file
BIN
tools/arm-none-eabi-gcc/4.8.3-2014q1/arm-none-eabi/bin/strip
Normal file
Binary file not shown.
|
|
@ -0,0 +1,144 @@
|
||||||
|
/* Provide support for both ANSI and non-ANSI environments. */
|
||||||
|
|
||||||
|
/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
|
||||||
|
relied upon to have it's intended meaning. Therefore we must use our own
|
||||||
|
concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib
|
||||||
|
sources!
|
||||||
|
|
||||||
|
To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will
|
||||||
|
"comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
|
||||||
|
files aren't affected). */
|
||||||
|
|
||||||
|
#ifndef _ANSIDECL_H_
|
||||||
|
#define _ANSIDECL_H_
|
||||||
|
|
||||||
|
#include <newlib.h>
|
||||||
|
#include <sys/config.h>
|
||||||
|
|
||||||
|
/* First try to figure out whether we really are in an ANSI C environment. */
|
||||||
|
/* FIXME: This probably needs some work. Perhaps sys/config.h can be
|
||||||
|
prevailed upon to give us a clue. */
|
||||||
|
|
||||||
|
#ifdef __STDC__
|
||||||
|
#define _HAVE_STDC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ISO C++. */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
|
||||||
|
#ifdef _HAVE_STD_CXX
|
||||||
|
#define _BEGIN_STD_C namespace std { extern "C" {
|
||||||
|
#define _END_STD_C } }
|
||||||
|
#else
|
||||||
|
#define _BEGIN_STD_C extern "C" {
|
||||||
|
#define _END_STD_C }
|
||||||
|
#endif
|
||||||
|
#if __GNUC_PREREQ (3, 3)
|
||||||
|
#define _NOTHROW __attribute__ ((nothrow))
|
||||||
|
#else
|
||||||
|
#define _NOTHROW throw()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define _BEGIN_STD_C
|
||||||
|
#define _END_STD_C
|
||||||
|
#define _NOTHROW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _HAVE_STDC
|
||||||
|
#define _PTR void *
|
||||||
|
#define _AND ,
|
||||||
|
#define _NOARGS void
|
||||||
|
#define _CONST const
|
||||||
|
#define _VOLATILE volatile
|
||||||
|
#define _SIGNED signed
|
||||||
|
#define _DOTS , ...
|
||||||
|
#define _VOID void
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW
|
||||||
|
#define _EXFUN(name, proto) __cdecl name proto
|
||||||
|
#define _EXPARM(name, proto) (* __cdecl name) proto
|
||||||
|
#define _EXFNPTR(name, proto) (__cdecl * name) proto
|
||||||
|
#else
|
||||||
|
#define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW
|
||||||
|
#define _EXFUN(name, proto) name proto
|
||||||
|
#define _EXPARM(name, proto) (* name) proto
|
||||||
|
#define _EXFNPTR(name, proto) (* name) proto
|
||||||
|
#endif
|
||||||
|
#define _DEFUN(name, arglist, args) name(args)
|
||||||
|
#define _DEFUN_VOID(name) name(_NOARGS)
|
||||||
|
#define _CAST_VOID (void)
|
||||||
|
#ifndef _LONG_DOUBLE
|
||||||
|
#define _LONG_DOUBLE long double
|
||||||
|
#endif
|
||||||
|
#ifndef _LONG_LONG_TYPE
|
||||||
|
#define _LONG_LONG_TYPE long long
|
||||||
|
#endif
|
||||||
|
#ifndef _PARAMS
|
||||||
|
#define _PARAMS(paramlist) paramlist
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define _PTR char *
|
||||||
|
#define _AND ;
|
||||||
|
#define _NOARGS
|
||||||
|
#define _CONST
|
||||||
|
#define _VOLATILE
|
||||||
|
#define _SIGNED
|
||||||
|
#define _DOTS
|
||||||
|
#define _VOID void
|
||||||
|
#define _EXFUN(name, proto) name()
|
||||||
|
#define _EXFUN_NOTHROW(name, proto) name()
|
||||||
|
#define _DEFUN(name, arglist, args) name arglist args;
|
||||||
|
#define _DEFUN_VOID(name) name()
|
||||||
|
#define _CAST_VOID
|
||||||
|
#define _LONG_DOUBLE double
|
||||||
|
#define _LONG_LONG_TYPE long
|
||||||
|
#ifndef _PARAMS
|
||||||
|
#define _PARAMS(paramlist) ()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Support gcc's __attribute__ facility. */
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
|
||||||
|
#else
|
||||||
|
#define _ATTRIBUTE(attrs)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The traditional meaning of 'extern inline' for GCC is not
|
||||||
|
to emit the function body unless the address is explicitly
|
||||||
|
taken. However this behaviour is changing to match the C99
|
||||||
|
standard, which uses 'extern inline' to indicate that the
|
||||||
|
function body *must* be emitted. Likewise, a function declared
|
||||||
|
without either 'extern' or 'static' defaults to extern linkage
|
||||||
|
(C99 6.2.2p5), and the compiler may choose whether to use the
|
||||||
|
inline version or call the extern linkage version (6.7.4p6).
|
||||||
|
If we are using GCC, but do not have the new behaviour, we need
|
||||||
|
to use extern inline; if we are using a new GCC with the
|
||||||
|
C99-compatible behaviour, or a non-GCC compiler (which we will
|
||||||
|
have to hope is C99, since there is no other way to achieve the
|
||||||
|
effect of omitting the function if it isn't referenced) we use
|
||||||
|
'static inline', which c99 defines to mean more-or-less the same
|
||||||
|
as the Gnu C 'extern inline'. */
|
||||||
|
#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
|
||||||
|
/* We're using GCC, but without the new C99-compatible behaviour. */
|
||||||
|
#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
|
||||||
|
#else
|
||||||
|
/* We're using GCC in C99 mode, or an unknown compiler which
|
||||||
|
we just have to hope obeys the C99 semantics of inline. */
|
||||||
|
#define _ELIDABLE_INLINE static __inline__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ (3, 1)
|
||||||
|
#define _NOINLINE __attribute__ ((__noinline__))
|
||||||
|
#define _NOINLINE_STATIC _NOINLINE static
|
||||||
|
#else
|
||||||
|
/* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be
|
||||||
|
trusted not to inline if it is static. */
|
||||||
|
#define _NOINLINE
|
||||||
|
#define _NOINLINE_STATIC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _ANSIDECL_H_ */
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
/* internal use only -- mapping of "system calls" for libraries that lose
|
||||||
|
and only provide C names, so that we end up in violation of ANSI */
|
||||||
|
#ifndef __SYSLIST_H
|
||||||
|
#define __SYSLIST_H
|
||||||
|
|
||||||
|
#ifdef MISSING_SYSCALL_NAMES
|
||||||
|
#define _close close
|
||||||
|
#define _execve execve
|
||||||
|
#define _fcntl fcntl
|
||||||
|
#define _fork fork
|
||||||
|
#define _fstat fstat
|
||||||
|
#define _getpid getpid
|
||||||
|
#define _gettimeofday gettimeofday
|
||||||
|
#define _isatty isatty
|
||||||
|
#define _kill kill
|
||||||
|
#define _link link
|
||||||
|
#define _lseek lseek
|
||||||
|
#define _mkdir mkdir
|
||||||
|
#define _open open
|
||||||
|
#define _read read
|
||||||
|
#define _sbrk sbrk
|
||||||
|
#define _stat stat
|
||||||
|
#define _times times
|
||||||
|
#define _unlink unlink
|
||||||
|
#define _wait wait
|
||||||
|
#define _write write
|
||||||
|
#endif /* MISSING_SYSCALL_NAMES */
|
||||||
|
|
||||||
|
#if defined MISSING_SYSCALL_NAMES || !defined HAVE_OPENDIR
|
||||||
|
/* If the system call interface is missing opendir, readdir, and
|
||||||
|
closedir, there is an implementation of these functions in
|
||||||
|
libc/posix that is implemented using open, getdents, and close.
|
||||||
|
Note, these functions are currently not in the libc/syscalls
|
||||||
|
directory. */
|
||||||
|
#define _opendir opendir
|
||||||
|
#define _readdir readdir
|
||||||
|
#define _closedir closedir
|
||||||
|
#endif /* MISSING_SYSCALL_NAMES || !HAVE_OPENDIR */
|
||||||
|
|
||||||
|
#endif /* !__SYSLIST_H_ */
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/* libc/include/alloca.h - Allocate memory on stack */
|
||||||
|
|
||||||
|
/* Written 2000 by Werner Almesberger */
|
||||||
|
/* Rearranged for general inclusion by stdlib.h.
|
||||||
|
2001, Corinna Vinschen <vinschen@redhat.com> */
|
||||||
|
|
||||||
|
#ifndef _NEWLIB_ALLOCA_H
|
||||||
|
#define _NEWLIB_ALLOCA_H
|
||||||
|
|
||||||
|
#include "_ansi.h"
|
||||||
|
#include <sys/reent.h>
|
||||||
|
|
||||||
|
#undef alloca
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define alloca(size) __builtin_alloca(size)
|
||||||
|
#else
|
||||||
|
void * _EXFUN(alloca,(size_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1991, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
* (c) UNIX System Laboratories, Inc.
|
||||||
|
* All or some portions of this file are derived from material licensed
|
||||||
|
* to the University of California by American Telephone and Telegraph
|
||||||
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
||||||
|
* the permission of UNIX System Laboratories, Inc.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Hugh Smith at The University of Guelph.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* @(#)ar.h 8.2 (Berkeley) 1/21/94
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _AR_H_
|
||||||
|
#define _AR_H_
|
||||||
|
|
||||||
|
/* Pre-4BSD archives had these magic numbers in them. */
|
||||||
|
#define OARMAG1 0177555
|
||||||
|
#define OARMAG2 0177545
|
||||||
|
|
||||||
|
#define ARMAG "!<arch>\n" /* ar "magic number" */
|
||||||
|
#define SARMAG 8 /* strlen(ARMAG); */
|
||||||
|
|
||||||
|
#define AR_EFMT1 "#1/" /* extended format #1 */
|
||||||
|
|
||||||
|
struct ar_hdr {
|
||||||
|
char ar_name[16]; /* name */
|
||||||
|
char ar_date[12]; /* modification time */
|
||||||
|
char ar_uid[6]; /* user id */
|
||||||
|
char ar_gid[6]; /* group id */
|
||||||
|
char ar_mode[8]; /* octal file permissions */
|
||||||
|
char ar_size[10]; /* size in bytes */
|
||||||
|
#define ARFMAG "`\n"
|
||||||
|
char ar_fmag[2]; /* consistency check */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_AR_H_ */
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software
|
||||||
|
* is freely granted, provided that this notice is preserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ARGZ_H_
|
||||||
|
#define _ARGZ_H_
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "_ansi.h"
|
||||||
|
|
||||||
|
_BEGIN_STD_C
|
||||||
|
|
||||||
|
/* The newlib implementation of these functions assumes that sizeof(char) == 1. */
|
||||||
|
error_t argz_create (char *const argv[], char **argz, size_t *argz_len);
|
||||||
|
error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len);
|
||||||
|
size_t argz_count (const char *argz, size_t argz_len);
|
||||||
|
void argz_extract (char *argz, size_t argz_len, char **argv);
|
||||||
|
void argz_stringify (char *argz, size_t argz_len, int sep);
|
||||||
|
error_t argz_add (char **argz, size_t *argz_len, const char *str);
|
||||||
|
error_t argz_add_sep (char **argz, size_t *argz_len, const char *str, int sep);
|
||||||
|
error_t argz_append (char **argz, size_t *argz_len, const char *buf, size_t buf_len);
|
||||||
|
error_t argz_delete (char **argz, size_t *argz_len, char *entry);
|
||||||
|
error_t argz_insert (char **argz, size_t *argz_len, char *before, const char *entry);
|
||||||
|
char * argz_next (char *argz, size_t argz_len, const char *entry);
|
||||||
|
error_t argz_replace (char **argz, size_t *argz_len, const char *str, const char *with, unsigned *replace_count);
|
||||||
|
|
||||||
|
_END_STD_C
|
||||||
|
|
||||||
|
#endif /* _ARGZ_H_ */
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
assert.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "_ansi.h"
|
||||||
|
|
||||||
|
#undef assert
|
||||||
|
|
||||||
|
#ifdef NDEBUG /* required by ANSI standard */
|
||||||
|
# define assert(__e) ((void)0)
|
||||||
|
#else
|
||||||
|
# define assert(__e) ((__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
|
||||||
|
__ASSERT_FUNC, #__e))
|
||||||
|
|
||||||
|
# ifndef __ASSERT_FUNC
|
||||||
|
/* Use g++'s demangled names in C++. */
|
||||||
|
# if defined __cplusplus && defined __GNUC__
|
||||||
|
# define __ASSERT_FUNC __PRETTY_FUNCTION__
|
||||||
|
|
||||||
|
/* C99 requires the use of __func__. */
|
||||||
|
# elif __STDC_VERSION__ >= 199901L
|
||||||
|
# define __ASSERT_FUNC __func__
|
||||||
|
|
||||||
|
/* Older versions of gcc don't have __func__ but can use __FUNCTION__. */
|
||||||
|
# elif __GNUC__ >= 2
|
||||||
|
# define __ASSERT_FUNC __FUNCTION__
|
||||||
|
|
||||||
|
/* failed to detect __func__ support. */
|
||||||
|
# else
|
||||||
|
# define __ASSERT_FUNC ((char *) 0)
|
||||||
|
# endif
|
||||||
|
# endif /* !__ASSERT_FUNC */
|
||||||
|
#endif /* !NDEBUG */
|
||||||
|
|
||||||
|
void _EXFUN(__assert, (const char *, int, const char *)
|
||||||
|
_ATTRIBUTE ((__noreturn__)));
|
||||||
|
void _EXFUN(__assert_func, (const char *, int, const char *, const char *)
|
||||||
|
_ATTRIBUTE ((__noreturn__)));
|
||||||
|
|
||||||
|
#if __STDC_VERSION__ >= 201112L && !defined __cplusplus
|
||||||
|
# define static_assert _Static_assert
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
// <algorithm> -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (c) 1994
|
||||||
|
* Hewlett-Packard Company
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute and sell this software
|
||||||
|
* and its documentation for any purpose is hereby granted without fee,
|
||||||
|
* provided that the above copyright notice appear in all copies and
|
||||||
|
* that both that copyright notice and this permission notice appear
|
||||||
|
* in supporting documentation. Hewlett-Packard Company makes no
|
||||||
|
* representations about the suitability of this software for any
|
||||||
|
* purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 1996,1997
|
||||||
|
* Silicon Graphics Computer Systems, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute and sell this software
|
||||||
|
* and its documentation for any purpose is hereby granted without fee,
|
||||||
|
* provided that the above copyright notice appear in all copies and
|
||||||
|
* that both that copyright notice and this permission notice appear
|
||||||
|
* in supporting documentation. Silicon Graphics makes no
|
||||||
|
* representations about the suitability of this software for any
|
||||||
|
* purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file include/algorithm
|
||||||
|
* This is a Standard C++ Library header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ALGORITHM
|
||||||
|
#define _GLIBCXX_ALGORITHM 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <utility> // UK-300.
|
||||||
|
#include <bits/stl_algobase.h>
|
||||||
|
#include <bits/stl_algo.h>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_PARALLEL
|
||||||
|
# include <parallel/algorithm>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _GLIBCXX_ALGORITHM */
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Low-level type for atomic operations -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file atomic_word.h
|
||||||
|
* This file is a GNU extension to the Standard C++ Library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ATOMIC_WORD_H
|
||||||
|
#define _GLIBCXX_ATOMIC_WORD_H 1
|
||||||
|
|
||||||
|
typedef int _Atomic_word;
|
||||||
|
|
||||||
|
// Define these two macros using the appropriate memory barrier for the target.
|
||||||
|
// The commented out versions below are the defaults.
|
||||||
|
// See ia64/atomic_word.h for an alternative approach.
|
||||||
|
|
||||||
|
// This one prevents loads from being hoisted across the barrier;
|
||||||
|
// in other words, this is a Load-Load acquire barrier.
|
||||||
|
// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h.
|
||||||
|
// #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
// This one prevents stores from being sunk across the barrier; in other
|
||||||
|
// words, a Store-Store release barrier.
|
||||||
|
// #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
// Wrapper of C-language FILE struct -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 27.8 File-based streams
|
||||||
|
//
|
||||||
|
|
||||||
|
/** @file bits/basic_file.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
|
||||||
|
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <bits/c++io.h> // for __c_lock and __c_file
|
||||||
|
#include <ios>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Generic declaration.
|
||||||
|
template<typename _CharT>
|
||||||
|
class __basic_file;
|
||||||
|
|
||||||
|
// Specialization.
|
||||||
|
template<>
|
||||||
|
class __basic_file<char>
|
||||||
|
{
|
||||||
|
// Underlying data source/sink.
|
||||||
|
__c_file* _M_cfile;
|
||||||
|
|
||||||
|
// True iff we opened _M_cfile, and thus must close it ourselves.
|
||||||
|
bool _M_cfile_created;
|
||||||
|
|
||||||
|
public:
|
||||||
|
__basic_file(__c_lock* __lock = 0) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(__c_file* __file, ios_base::openmode);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(int __fd, ios_base::openmode __mode) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
close();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE bool
|
||||||
|
is_open() const throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE int
|
||||||
|
fd() throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE __c_file*
|
||||||
|
file() throw ();
|
||||||
|
|
||||||
|
~__basic_file();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn(const char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn_2(const char* __s1, streamsize __n1,
|
||||||
|
const char* __s2, streamsize __n2);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsgetn(char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamoff
|
||||||
|
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
|
||||||
|
|
||||||
|
int
|
||||||
|
sync();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
showmanyc();
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
// Base to std::allocator -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++allocator.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{memory}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
|
||||||
|
#define _GLIBCXX_CXX_ALLOCATOR_H 1
|
||||||
|
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief An alias to the base class for std::allocator.
|
||||||
|
* @ingroup allocators
|
||||||
|
*
|
||||||
|
* Used to set the std::allocator base class to
|
||||||
|
* __gnu_cxx::new_allocator.
|
||||||
|
*
|
||||||
|
* @tparam _Tp Type of allocated object.
|
||||||
|
*/
|
||||||
|
template<typename _Tp>
|
||||||
|
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Define new_allocator as the base class to std::allocator.
|
||||||
|
# define __allocator_base __gnu_cxx::new_allocator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Underlying io library details -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++io.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// c_io_stdio.h - Defines for using "C" stdio.h
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_IO_H
|
||||||
|
#define _GLIBCXX_CXX_IO_H 1
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef __gthread_mutex_t __c_lock;
|
||||||
|
|
||||||
|
// for basic_file.h
|
||||||
|
typedef FILE __c_file;
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// Wrapper for underlying C-language localization -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++locale.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.8 Standard locale categories.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_LOCALE_H
|
||||||
|
#define _GLIBCXX_CXX_LOCALE_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <clocale>
|
||||||
|
|
||||||
|
#define _GLIBCXX_NUM_CATEGORIES 0
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef int* __c_locale;
|
||||||
|
|
||||||
|
// Convert numeric value of type double and long double to string and
|
||||||
|
// return length of string. If vsnprintf is available use it, otherwise
|
||||||
|
// fall back to the unsafe vsprintf which, in general, can be dangerous
|
||||||
|
// and should be avoided.
|
||||||
|
inline int
|
||||||
|
__convert_from_v(const __c_locale&, char* __out,
|
||||||
|
const int __size __attribute__((__unused__)),
|
||||||
|
const char* __fmt, ...)
|
||||||
|
{
|
||||||
|
char* __old = std::setlocale(LC_NUMERIC, 0);
|
||||||
|
char* __sav = 0;
|
||||||
|
if (__builtin_strcmp(__old, "C"))
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__old) + 1;
|
||||||
|
__sav = new char[__len];
|
||||||
|
__builtin_memcpy(__sav, __old, __len);
|
||||||
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
}
|
||||||
|
|
||||||
|
__builtin_va_list __args;
|
||||||
|
__builtin_va_start(__args, __fmt);
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_USE_C99
|
||||||
|
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
|
||||||
|
#else
|
||||||
|
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__builtin_va_end(__args);
|
||||||
|
|
||||||
|
if (__sav)
|
||||||
|
{
|
||||||
|
std::setlocale(LC_NUMERIC, __sav);
|
||||||
|
delete [] __sav;
|
||||||
|
}
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2005-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cpu_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CPU_DEFINES
|
||||||
|
#define _GLIBCXX_CPU_DEFINES 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
|
||||||
|
|
||||||
|
// Support for Solaris 2.5.1
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
/// @brief Base class for ctype.
|
||||||
|
struct ctype_base
|
||||||
|
{
|
||||||
|
// Non-standard typedefs.
|
||||||
|
typedef const int* __to_type;
|
||||||
|
|
||||||
|
// NB: Offsets into ctype<char>::_M_table force a particular size
|
||||||
|
// on the mask type. Because of this, we don't use an enum.
|
||||||
|
typedef char mask;
|
||||||
|
static const mask upper = _U;
|
||||||
|
static const mask lower = _L;
|
||||||
|
static const mask alpha = _U | _L;
|
||||||
|
static const mask digit = _N;
|
||||||
|
static const mask xdigit = _X | _N;
|
||||||
|
static const mask space = _S;
|
||||||
|
static const mask print = _P | _U | _L | _N | _B;
|
||||||
|
static const mask graph = _P | _U | _L | _N;
|
||||||
|
static const mask cntrl = _C;
|
||||||
|
static const mask punct = _P;
|
||||||
|
static const mask alnum = _U | _L | _N;
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/ctype_inline.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
|
||||||
|
// functions go in ctype.cc
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
bool
|
||||||
|
ctype<char>::
|
||||||
|
is(mask __m, char __c) const
|
||||||
|
{ return _M_table[static_cast<unsigned char>(__c)] & __m; }
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
is(const char* __low, const char* __high, mask* __vec) const
|
||||||
|
{
|
||||||
|
while (__low < __high)
|
||||||
|
*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
|
||||||
|
return __high;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_is(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && !this->is(__m, *__low))
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_not(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && this->is(__m, *__low) != 0)
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Control various target specific ABI tweaks. ARM version.
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cxxabi_tweaks.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{cxxabi.h}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CXXABI_TWEAKS_H
|
||||||
|
#define _CXXABI_TWEAKS_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace __cxxabiv1
|
||||||
|
{
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ARM_EABI__
|
||||||
|
// The ARM EABI uses the least significant bit of a 32-bit
|
||||||
|
// guard variable. */
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT 1
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
typedef int __guard;
|
||||||
|
|
||||||
|
// We also want the element size in array cookies.
|
||||||
|
#define _GLIBCXX_ELTSIZE_IN_COOKIE 1
|
||||||
|
|
||||||
|
// __cxa_vec_ctor should return a pointer to the array.
|
||||||
|
typedef void * __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x
|
||||||
|
// Constructors and destructors return the "this" pointer.
|
||||||
|
typedef void * __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#else // __ARM_EABI__
|
||||||
|
|
||||||
|
// The generic ABI uses the first byte of a 64-bit guard variable.
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
__extension__ typedef int __guard __attribute__((mode (__DI__)));
|
||||||
|
|
||||||
|
// __cxa_vec_ctor has void return type.
|
||||||
|
typedef void __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
|
||||||
|
// Constructors and destructors do not return a value.
|
||||||
|
typedef void __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#endif //!__ARM_EABI__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
} // namespace __cxxabiv1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/error_constants.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{system_error}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ERROR_CONSTANTS
|
||||||
|
#define _GLIBCXX_ERROR_CONSTANTS 1
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
enum class errc
|
||||||
|
{
|
||||||
|
address_family_not_supported = EAFNOSUPPORT,
|
||||||
|
address_in_use = EADDRINUSE,
|
||||||
|
address_not_available = EADDRNOTAVAIL,
|
||||||
|
already_connected = EISCONN,
|
||||||
|
argument_list_too_long = E2BIG,
|
||||||
|
argument_out_of_domain = EDOM,
|
||||||
|
bad_address = EFAULT,
|
||||||
|
bad_file_descriptor = EBADF,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EBADMSG
|
||||||
|
bad_message = EBADMSG,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
broken_pipe = EPIPE,
|
||||||
|
connection_aborted = ECONNABORTED,
|
||||||
|
connection_already_in_progress = EALREADY,
|
||||||
|
connection_refused = ECONNREFUSED,
|
||||||
|
connection_reset = ECONNRESET,
|
||||||
|
cross_device_link = EXDEV,
|
||||||
|
destination_address_required = EDESTADDRREQ,
|
||||||
|
device_or_resource_busy = EBUSY,
|
||||||
|
directory_not_empty = ENOTEMPTY,
|
||||||
|
executable_format_error = ENOEXEC,
|
||||||
|
file_exists = EEXIST,
|
||||||
|
file_too_large = EFBIG,
|
||||||
|
filename_too_long = ENAMETOOLONG,
|
||||||
|
function_not_supported = ENOSYS,
|
||||||
|
host_unreachable = EHOSTUNREACH,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EIDRM
|
||||||
|
identifier_removed = EIDRM,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
illegal_byte_sequence = EILSEQ,
|
||||||
|
inappropriate_io_control_operation = ENOTTY,
|
||||||
|
interrupted = EINTR,
|
||||||
|
invalid_argument = EINVAL,
|
||||||
|
invalid_seek = ESPIPE,
|
||||||
|
io_error = EIO,
|
||||||
|
is_a_directory = EISDIR,
|
||||||
|
message_size = EMSGSIZE,
|
||||||
|
network_down = ENETDOWN,
|
||||||
|
network_reset = ENETRESET,
|
||||||
|
network_unreachable = ENETUNREACH,
|
||||||
|
no_buffer_space = ENOBUFS,
|
||||||
|
no_child_process = ECHILD,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOLINK
|
||||||
|
no_link = ENOLINK,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_lock_available = ENOLCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENODATA
|
||||||
|
no_message_available = ENODATA,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_message = ENOMSG,
|
||||||
|
no_protocol_option = ENOPROTOOPT,
|
||||||
|
no_space_on_device = ENOSPC,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSR
|
||||||
|
no_stream_resources = ENOSR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_such_device_or_address = ENXIO,
|
||||||
|
no_such_device = ENODEV,
|
||||||
|
no_such_file_or_directory = ENOENT,
|
||||||
|
no_such_process = ESRCH,
|
||||||
|
not_a_directory = ENOTDIR,
|
||||||
|
not_a_socket = ENOTSOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSTR
|
||||||
|
not_a_stream = ENOSTR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
not_connected = ENOTCONN,
|
||||||
|
not_enough_memory = ENOMEM,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTSUP
|
||||||
|
not_supported = ENOTSUP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ECANCELED
|
||||||
|
operation_canceled = ECANCELED,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
operation_in_progress = EINPROGRESS,
|
||||||
|
operation_not_permitted = EPERM,
|
||||||
|
operation_not_supported = EOPNOTSUPP,
|
||||||
|
operation_would_block = EWOULDBLOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
|
||||||
|
owner_dead = EOWNERDEAD,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
permission_denied = EACCES,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EPROTO
|
||||||
|
protocol_error = EPROTO,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protocol_not_supported = EPROTONOSUPPORT,
|
||||||
|
read_only_file_system = EROFS,
|
||||||
|
resource_deadlock_would_occur = EDEADLK,
|
||||||
|
resource_unavailable_try_again = EAGAIN,
|
||||||
|
result_out_of_range = ERANGE,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
|
||||||
|
state_not_recoverable = ENOTRECOVERABLE,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETIME
|
||||||
|
stream_timeout = ETIME,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETXTBSY
|
||||||
|
text_file_busy = ETXTBSY,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
timed_out = ETIMEDOUT,
|
||||||
|
too_many_files_open_in_system = ENFILE,
|
||||||
|
too_many_files_open = EMFILE,
|
||||||
|
too_many_links = EMLINK,
|
||||||
|
too_many_symbolic_link_levels = ELOOP,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOVERFLOW
|
||||||
|
value_too_large = EOVERFLOW,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wrong_protocol_type = EPROTOTYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
// C++ includes used for precompiling extensions -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file extc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
|
#include <bits/stdtr1c++.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ext/algorithm>
|
||||||
|
#include <ext/array_allocator.h>
|
||||||
|
#include <ext/atomicity.h>
|
||||||
|
#include <ext/bitmap_allocator.h>
|
||||||
|
#include <ext/cast.h>
|
||||||
|
#include <ext/concurrence.h>
|
||||||
|
#include <ext/debug_allocator.h>
|
||||||
|
#include <ext/extptr_allocator.h>
|
||||||
|
#include <ext/functional>
|
||||||
|
#include <ext/iterator>
|
||||||
|
#include <ext/malloc_allocator.h>
|
||||||
|
#include <ext/memory>
|
||||||
|
#include <ext/mt_allocator.h>
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
#include <ext/numeric>
|
||||||
|
#include <ext/pod_char_traits.h>
|
||||||
|
#include <ext/pointer.h>
|
||||||
|
#include <ext/pool_allocator.h>
|
||||||
|
#include <ext/rb_tree>
|
||||||
|
#include <ext/rope>
|
||||||
|
#include <ext/slist>
|
||||||
|
#include <ext/stdio_filebuf.h>
|
||||||
|
#include <ext/stdio_sync_filebuf.h>
|
||||||
|
#include <ext/throw_allocator.h>
|
||||||
|
#include <ext/typelist.h>
|
||||||
|
#include <ext/type_traits.h>
|
||||||
|
#include <ext/vstring.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/priority_queue.hpp>
|
||||||
|
#include <ext/pb_ds/exception.hpp>
|
||||||
|
#include <ext/pb_ds/hash_policy.hpp>
|
||||||
|
#include <ext/pb_ds/list_update_policy.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
#include <ext/pb_ds/trie_policy.hpp>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ICONV
|
||||||
|
#include <ext/codecvt_specializations.h>
|
||||||
|
#include <ext/enc_filebuf.h>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,889 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
|
||||||
|
/* POSIX threads specific definitions.
|
||||||
|
Easy, since the interface is just one-to-one mapping. */
|
||||||
|
|
||||||
|
#define __GTHREADS 1
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|
||||||
|
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
|
||||||
|
# include <unistd.h>
|
||||||
|
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
|
||||||
|
# else
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef pthread_t __gthread_t;
|
||||||
|
typedef pthread_key_t __gthread_key_t;
|
||||||
|
typedef pthread_once_t __gthread_once_t;
|
||||||
|
typedef pthread_mutex_t __gthread_mutex_t;
|
||||||
|
typedef pthread_mutex_t __gthread_recursive_mutex_t;
|
||||||
|
typedef pthread_cond_t __gthread_cond_t;
|
||||||
|
typedef struct timespec __gthread_time_t;
|
||||||
|
|
||||||
|
/* POSIX like conditional variables are supported. Please look at comments
|
||||||
|
in gthr.h for details. */
|
||||||
|
#define __GTHREAD_HAS_COND 1
|
||||||
|
|
||||||
|
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
|
||||||
|
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
||||||
|
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||||
|
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||||
|
#else
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
|
||||||
|
#define __GTHREAD_TIME_INIT {0,0}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_MUTEX_INIT
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
# undef __GTHREAD_COND_INIT
|
||||||
|
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
# ifndef __gthrw_pragma
|
||||||
|
# define __gthrw_pragma(pragma)
|
||||||
|
# endif
|
||||||
|
# define __gthrw2(name,name2,type) \
|
||||||
|
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
|
||||||
|
__gthrw_pragma(weak type)
|
||||||
|
# define __gthrw_(name) __gthrw_ ## name
|
||||||
|
#else
|
||||||
|
# define __gthrw2(name,name2,type)
|
||||||
|
# define __gthrw_(name) name
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
|
||||||
|
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
|
||||||
|
|
||||||
|
__gthrw(pthread_once)
|
||||||
|
__gthrw(pthread_getspecific)
|
||||||
|
__gthrw(pthread_setspecific)
|
||||||
|
|
||||||
|
__gthrw(pthread_create)
|
||||||
|
__gthrw(pthread_join)
|
||||||
|
__gthrw(pthread_equal)
|
||||||
|
__gthrw(pthread_self)
|
||||||
|
__gthrw(pthread_detach)
|
||||||
|
#ifndef __BIONIC__
|
||||||
|
__gthrw(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
__gthrw(sched_yield)
|
||||||
|
|
||||||
|
__gthrw(pthread_mutex_lock)
|
||||||
|
__gthrw(pthread_mutex_trylock)
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
__gthrw(pthread_mutex_timedlock)
|
||||||
|
#endif
|
||||||
|
__gthrw(pthread_mutex_unlock)
|
||||||
|
__gthrw(pthread_mutex_init)
|
||||||
|
__gthrw(pthread_mutex_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_cond_init)
|
||||||
|
__gthrw(pthread_cond_broadcast)
|
||||||
|
__gthrw(pthread_cond_signal)
|
||||||
|
__gthrw(pthread_cond_wait)
|
||||||
|
__gthrw(pthread_cond_timedwait)
|
||||||
|
__gthrw(pthread_cond_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_key_create)
|
||||||
|
__gthrw(pthread_key_delete)
|
||||||
|
__gthrw(pthread_mutexattr_init)
|
||||||
|
__gthrw(pthread_mutexattr_settype)
|
||||||
|
__gthrw(pthread_mutexattr_destroy)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
|
||||||
|
/* Objective-C. */
|
||||||
|
__gthrw(pthread_exit)
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(sched_get_priority_max)
|
||||||
|
__gthrw(sched_get_priority_min)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
__gthrw(pthread_attr_destroy)
|
||||||
|
__gthrw(pthread_attr_init)
|
||||||
|
__gthrw(pthread_attr_setdetachstate)
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(pthread_getschedparam)
|
||||||
|
__gthrw(pthread_setschedparam)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
|
||||||
|
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
|
||||||
|
-pthreads is not specified. The functions are dummies and most return an
|
||||||
|
error value. However pthread_once returns 0 without invoking the routine
|
||||||
|
it is passed so we cannot pretend that the interface is active if -pthreads
|
||||||
|
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
|
||||||
|
we need to play the usual game with weak symbols. On Solaris 10 and up, a
|
||||||
|
working interface is always exposed. On FreeBSD 6 and later, libc also
|
||||||
|
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
|
||||||
|
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
|
||||||
|
which means the alternate __gthread_active_p below cannot be used there. */
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static void
|
||||||
|
__gthread_trigger (void)
|
||||||
|
{
|
||||||
|
__gthread_active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
|
||||||
|
/* This test is not protected to avoid taking a lock on the main code
|
||||||
|
path so every update of __gthread_active in a threaded program must
|
||||||
|
be atomic with regard to the result of the test. */
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_once))
|
||||||
|
{
|
||||||
|
/* If this really is a threaded program, then we must ensure that
|
||||||
|
__gthread_active has been set to 1 before exiting this block. */
|
||||||
|
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||||
|
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
|
||||||
|
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure we'll never enter this block again. */
|
||||||
|
if (__gthread_active < 0)
|
||||||
|
__gthread_active = 0;
|
||||||
|
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* neither FreeBSD nor Solaris */
|
||||||
|
|
||||||
|
/* For a program to be multi-threaded the only thing that it certainly must
|
||||||
|
be using is pthread_create. However, there may be other libraries that
|
||||||
|
intercept pthread_create with their own definitions to wrap pthreads
|
||||||
|
functionality for some purpose. In those cases, pthread_create being
|
||||||
|
defined might not necessarily mean that libpthread is actually linked
|
||||||
|
in.
|
||||||
|
|
||||||
|
For the GNU C library, we can use a known internal name. This is always
|
||||||
|
available in the ABI, but no other library would define it. That is
|
||||||
|
ideal, since any public pthread function might be intercepted just as
|
||||||
|
pthread_create might be. __pthread_key_create is an "internal"
|
||||||
|
implementation symbol, but it is part of the public exported ABI. Also,
|
||||||
|
it's among the symbols that the static libpthread.a always links in
|
||||||
|
whenever pthread_create is used, so there is no danger of a false
|
||||||
|
negative result in any statically-linked, multi-threaded program.
|
||||||
|
|
||||||
|
For others, we choose pthread_cancel as a function that seems unlikely
|
||||||
|
to be redefined by an interceptor library. The bionic (Android) C
|
||||||
|
library does not provide pthread_cancel, so we do use pthread_create
|
||||||
|
there (and interceptor libraries lose). */
|
||||||
|
|
||||||
|
#ifdef __GLIBC__
|
||||||
|
__gthrw2(__gthrw_(__pthread_key_create),
|
||||||
|
__pthread_key_create,
|
||||||
|
pthread_key_create)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
|
||||||
|
#elif defined (__BIONIC__)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
|
||||||
|
#else
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static void *const __gthread_active_ptr
|
||||||
|
= __extension__ (void *) >HR_ACTIVE_PROXY;
|
||||||
|
return __gthread_active_ptr != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FreeBSD or Solaris */
|
||||||
|
|
||||||
|
#else /* not __GXX_WEAK__ */
|
||||||
|
|
||||||
|
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
|
||||||
|
calls in shared flavors of the HP-UX C library. Most of the stubs
|
||||||
|
have no functionality. The details are described in the "libc cumulative
|
||||||
|
patch" for each subversion of HP-UX 11. There are two special interfaces
|
||||||
|
provided for checking whether an application is linked to a shared pthread
|
||||||
|
library or not. However, these interfaces aren't available in early
|
||||||
|
libpthread libraries. We also need a test that works for archive
|
||||||
|
libraries. We can't use pthread_once as some libc versions call the
|
||||||
|
init function. We also can't use pthread_create or pthread_attr_init
|
||||||
|
as these create a thread and thereby prevent changing the default stack
|
||||||
|
size. The function pthread_default_stacksize_np is available in both
|
||||||
|
the archive and shared versions of libpthread. It can be used to
|
||||||
|
determine the default pthread stack size. There is a stub in some
|
||||||
|
shared libc versions which returns a zero size if pthreads are not
|
||||||
|
active. We provide an equivalent stub to handle cases where libc
|
||||||
|
doesn't provide one. */
|
||||||
|
|
||||||
|
#if defined(__hppa__) && defined(__hpux__)
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
size_t __s;
|
||||||
|
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
pthread_default_stacksize_np (0, &__s);
|
||||||
|
__gthread_active = __s ? 1 : 0;
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* not hppa-hpux */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* hppa-hpux */
|
||||||
|
|
||||||
|
#endif /* __GXX_WEAK__ */
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* This is the config.h file in libobjc/ */
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
|
# include <sched.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Key structure for maintaining thread specific storage */
|
||||||
|
static pthread_key_t _objc_thread_storage;
|
||||||
|
static pthread_attr_t _objc_thread_attribs;
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
/* Initialize the thread storage key. */
|
||||||
|
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
|
||||||
|
{
|
||||||
|
/* The normal default detach state for threads is
|
||||||
|
* PTHREAD_CREATE_JOINABLE which causes threads to not die
|
||||||
|
* when you think they should. */
|
||||||
|
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
|
||||||
|
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
|
||||||
|
PTHREAD_CREATE_DETACHED) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
|
||||||
|
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
|
||||||
|
{
|
||||||
|
objc_thread_t thread_id;
|
||||||
|
pthread_t new_thread_handle;
|
||||||
|
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
|
||||||
|
(void *) func, arg)))
|
||||||
|
thread_id = (objc_thread_t) new_thread_handle;
|
||||||
|
else
|
||||||
|
thread_id = NULL;
|
||||||
|
|
||||||
|
return thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority)
|
||||||
|
{
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
pthread_t thread_id = __gthrw_(pthread_self) ();
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
int priority_min, priority_max;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
|
||||||
|
{
|
||||||
|
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (priority > priority_max)
|
||||||
|
priority = priority_max;
|
||||||
|
else if (priority < priority_min)
|
||||||
|
priority = priority_min;
|
||||||
|
params.sched_priority = priority;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The solaris 7 and several other man pages incorrectly state that
|
||||||
|
* this should be a pointer to policy but pthread.h is universally
|
||||||
|
* at odds with this.
|
||||||
|
*/
|
||||||
|
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
|
||||||
|
return params.sched_priority;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
/* exit the thread */
|
||||||
|
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
|
||||||
|
|
||||||
|
/* Failed if we reached here */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return (objc_thread_t) __gthrw_(pthread_self) ();
|
||||||
|
else
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
|
||||||
|
else
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Posix Threads specifically require that the thread be unlocked
|
||||||
|
* for __gthrw_(pthread_mutex_destroy) to work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
|
||||||
|
if (count < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while (count);
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
condition->backend = objc_malloc (sizeof (pthread_cond_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
|
||||||
|
(pthread_mutex_t *) mutex->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
|
||||||
|
void *__args)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_join (__gthread_t __threadid, void **__value_ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_join) (__threadid, __value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_detach (__gthread_t __threadid)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_detach) (__threadid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_equal) (__t1, __t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __gthread_t
|
||||||
|
__gthread_self (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_self) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_yield (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_once) (__once, __func);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_delete (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_delete) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_getspecific) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_mutex_init) (__mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|
||||||
|
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
pthread_mutexattr_t __attr;
|
||||||
|
int __r;
|
||||||
|
|
||||||
|
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
|
||||||
|
PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
|
||||||
|
return __r;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
static inline void
|
||||||
|
__gthread_cond_init_function (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_cond_init) (__cond, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_broadcast (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_broadcast) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_signal (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_signal) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
|
||||||
|
__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_cond_wait (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_destroy (__gthread_cond_t* __cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_destroy) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
/* Threads compatibility routines for libgcc2. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_H
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If this file is compiled with threads support, it must
|
||||||
|
#define __GTHREADS 1
|
||||||
|
to indicate that threads support is present. Also it has define
|
||||||
|
function
|
||||||
|
int __gthread_active_p ()
|
||||||
|
that returns 1 if thread system is active, 0 if not.
|
||||||
|
|
||||||
|
The threads interface must define the following types:
|
||||||
|
__gthread_key_t
|
||||||
|
__gthread_once_t
|
||||||
|
__gthread_mutex_t
|
||||||
|
__gthread_recursive_mutex_t
|
||||||
|
|
||||||
|
The threads interface must define the following macros:
|
||||||
|
|
||||||
|
__GTHREAD_ONCE_INIT
|
||||||
|
to initialize __gthread_once_t
|
||||||
|
__GTHREAD_MUTEX_INIT
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
__GTHREAD_MUTEX_INIT_FUNCTION
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
Define this to a function which looks like this:
|
||||||
|
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
|
||||||
|
Some systems can't initialize a mutex without a
|
||||||
|
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
as above, but for a recursive mutex.
|
||||||
|
|
||||||
|
The threads interface must define the following static functions:
|
||||||
|
|
||||||
|
int __gthread_once (__gthread_once_t *once, void (*func) ())
|
||||||
|
|
||||||
|
int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
|
||||||
|
int __gthread_key_delete (__gthread_key_t key)
|
||||||
|
|
||||||
|
void *__gthread_getspecific (__gthread_key_t key)
|
||||||
|
int __gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||||
|
|
||||||
|
int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_mutex_lock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
The following are supported in POSIX threads only. They are required to
|
||||||
|
fix a deadlock in static initialization inside libsupc++. The header file
|
||||||
|
gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
|
||||||
|
features are supported.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_cond_t
|
||||||
|
|
||||||
|
Macros:
|
||||||
|
__GTHREAD_COND_INIT
|
||||||
|
__GTHREAD_COND_INIT_FUNCTION
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_cond_broadcast (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
|
||||||
|
int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
||||||
|
__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
All functions returning int should return zero on success or the error
|
||||||
|
number. If the operation is not supported, -1 is returned.
|
||||||
|
|
||||||
|
If the following are also defined, you should
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
to enable the c++0x thread library.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_t
|
||||||
|
__gthread_time_t
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_create (__gthread_t *thread, void *(*func) (void*),
|
||||||
|
void *args);
|
||||||
|
int __gthread_join (__gthread_t thread, void **value_ptr);
|
||||||
|
int __gthread_detach (__gthread_t thread);
|
||||||
|
int __gthread_equal (__gthread_t t1, __gthread_t t2);
|
||||||
|
__gthread_t __gthread_self (void);
|
||||||
|
int __gthread_yield (void);
|
||||||
|
|
||||||
|
int __gthread_mutex_timedlock (__gthread_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_time);
|
||||||
|
|
||||||
|
int __gthread_cond_signal (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_timedwait (__gthread_cond_t *cond,
|
||||||
|
__gthread_mutex_t *mutex,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __GXX_WEAK__
|
||||||
|
/* The pe-coff weak support isn't fully compatible to ELF's weak.
|
||||||
|
For static libraries it might would work, but as we need to deal
|
||||||
|
with shared versions too, we disable it for mingw-targets. */
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#undef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include <bits/gthr-default.h>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_H */
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::messages implementation details, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/messages_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Non-virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(__c_locale, const char*, size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
|
||||||
|
const char*) const
|
||||||
|
{ return this->do_open(__s, __loc); }
|
||||||
|
|
||||||
|
// Virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::~messages()
|
||||||
|
{ _S_destroy_c_locale(_M_c_locale_messages); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::do_open(const basic_string<char>&, const locale&) const
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::string_type
|
||||||
|
messages<_CharT>::do_get(catalog, int, int,
|
||||||
|
const string_type& __dfault) const
|
||||||
|
{ return __dfault; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
void
|
||||||
|
messages<_CharT>::do_close(catalog) const
|
||||||
|
{ }
|
||||||
|
|
||||||
|
// messages_byname
|
||||||
|
template<typename _CharT>
|
||||||
|
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
|
||||||
|
: messages<_CharT>(__refs)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, "C") != 0
|
||||||
|
&& __builtin_strcmp(__s, "POSIX") != 0)
|
||||||
|
{
|
||||||
|
this->_S_destroy_c_locale(this->_M_c_locale_messages);
|
||||||
|
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number handling, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BITS_OPT_RANDOM_H
|
||||||
|
#define _BITS_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _BITS_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Specific definitions for newlib -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/os_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_OS_DEFINES
|
||||||
|
#define _GLIBCXX_OS_DEFINES 1
|
||||||
|
|
||||||
|
// System-specific #define, typedefs, corrections, etc, go here. This
|
||||||
|
// file will come before all others.
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
|
||||||
|
#if defined (_GLIBCXX_DLL)
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default __attribute__ ((__dllimport__))
|
||||||
|
#else
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default
|
||||||
|
#endif
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_hidden
|
||||||
|
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY_ ## V
|
||||||
|
|
||||||
|
// See libstdc++/20806.
|
||||||
|
#define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
// C++ includes used for precompiling -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 17.4.1.2 Headers
|
||||||
|
|
||||||
|
// C
|
||||||
|
#ifndef _GLIBCXX_NO_ASSERT
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
#include <cctype>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <ciso646>
|
||||||
|
#include <climits>
|
||||||
|
#include <clocale>
|
||||||
|
#include <cmath>
|
||||||
|
#include <csetjmp>
|
||||||
|
#include <csignal>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <ccomplex>
|
||||||
|
#include <cfenv>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstdalign>
|
||||||
|
#include <cstdbool>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ctgmath>
|
||||||
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++
|
||||||
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <complex>
|
||||||
|
#include <deque>
|
||||||
|
#include <exception>
|
||||||
|
#include <fstream>
|
||||||
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <list>
|
||||||
|
#include <locale>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <new>
|
||||||
|
#include <numeric>
|
||||||
|
#include <ostream>
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stack>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <utility>
|
||||||
|
#include <valarray>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <array>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <forward_list>
|
||||||
|
#include <future>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <mutex>
|
||||||
|
#include <random>
|
||||||
|
#include <ratio>
|
||||||
|
#include <regex>
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <system_error>
|
||||||
|
#include <thread>
|
||||||
|
#include <tuple>
|
||||||
|
#include <typeindex>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
// C++ includes used for precompiling TR1 -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdtr1c++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
#include <tr1/array>
|
||||||
|
#include <tr1/cctype>
|
||||||
|
#include <tr1/cfenv>
|
||||||
|
#include <tr1/cfloat>
|
||||||
|
#include <tr1/cinttypes>
|
||||||
|
#include <tr1/climits>
|
||||||
|
#include <tr1/cmath>
|
||||||
|
#include <tr1/complex>
|
||||||
|
#include <tr1/cstdarg>
|
||||||
|
#include <tr1/cstdbool>
|
||||||
|
#include <tr1/cstdint>
|
||||||
|
#include <tr1/cstdio>
|
||||||
|
#include <tr1/cstdlib>
|
||||||
|
#include <tr1/ctgmath>
|
||||||
|
#include <tr1/ctime>
|
||||||
|
#include <tr1/cwchar>
|
||||||
|
#include <tr1/cwctype>
|
||||||
|
#include <tr1/functional>
|
||||||
|
#include <tr1/random>
|
||||||
|
#include <tr1/tuple>
|
||||||
|
#include <tr1/unordered_map>
|
||||||
|
#include <tr1/unordered_set>
|
||||||
|
#include <tr1/utility>
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/time_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.5.1.2 - time_get functions
|
||||||
|
// ISO C++ 14882: 22.2.5.3.2 - time_put functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
|
||||||
|
: facet(__refs), _M_data(__cache)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
|
||||||
|
size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__s) + 1;
|
||||||
|
char* __tmp = new char[__len];
|
||||||
|
__builtin_memcpy(__tmp, __s, __len);
|
||||||
|
_M_name_timepunct = __tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
|
||||||
|
__try
|
||||||
|
{ _M_initialize_timepunct(__cloc); }
|
||||||
|
__catch(...)
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
__throw_exception_again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::~__timepunct()
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
delete _M_data;
|
||||||
|
_S_destroy_c_locale(_M_c_locale_timepunct);
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number extensions, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file ext/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ext/random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EXT_OPT_RANDOM_H
|
||||||
|
#define _EXT_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _EXT_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Low-level type for atomic operations -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file atomic_word.h
|
||||||
|
* This file is a GNU extension to the Standard C++ Library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ATOMIC_WORD_H
|
||||||
|
#define _GLIBCXX_ATOMIC_WORD_H 1
|
||||||
|
|
||||||
|
typedef int _Atomic_word;
|
||||||
|
|
||||||
|
// Define these two macros using the appropriate memory barrier for the target.
|
||||||
|
// The commented out versions below are the defaults.
|
||||||
|
// See ia64/atomic_word.h for an alternative approach.
|
||||||
|
|
||||||
|
// This one prevents loads from being hoisted across the barrier;
|
||||||
|
// in other words, this is a Load-Load acquire barrier.
|
||||||
|
// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h.
|
||||||
|
// #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
// This one prevents stores from being sunk across the barrier; in other
|
||||||
|
// words, a Store-Store release barrier.
|
||||||
|
// #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
// Wrapper of C-language FILE struct -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 27.8 File-based streams
|
||||||
|
//
|
||||||
|
|
||||||
|
/** @file bits/basic_file.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
|
||||||
|
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <bits/c++io.h> // for __c_lock and __c_file
|
||||||
|
#include <ios>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Generic declaration.
|
||||||
|
template<typename _CharT>
|
||||||
|
class __basic_file;
|
||||||
|
|
||||||
|
// Specialization.
|
||||||
|
template<>
|
||||||
|
class __basic_file<char>
|
||||||
|
{
|
||||||
|
// Underlying data source/sink.
|
||||||
|
__c_file* _M_cfile;
|
||||||
|
|
||||||
|
// True iff we opened _M_cfile, and thus must close it ourselves.
|
||||||
|
bool _M_cfile_created;
|
||||||
|
|
||||||
|
public:
|
||||||
|
__basic_file(__c_lock* __lock = 0) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(__c_file* __file, ios_base::openmode);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(int __fd, ios_base::openmode __mode) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
close();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE bool
|
||||||
|
is_open() const throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE int
|
||||||
|
fd() throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE __c_file*
|
||||||
|
file() throw ();
|
||||||
|
|
||||||
|
~__basic_file();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn(const char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn_2(const char* __s1, streamsize __n1,
|
||||||
|
const char* __s2, streamsize __n2);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsgetn(char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamoff
|
||||||
|
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
|
||||||
|
|
||||||
|
int
|
||||||
|
sync();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
showmanyc();
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
// Base to std::allocator -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++allocator.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{memory}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
|
||||||
|
#define _GLIBCXX_CXX_ALLOCATOR_H 1
|
||||||
|
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief An alias to the base class for std::allocator.
|
||||||
|
* @ingroup allocators
|
||||||
|
*
|
||||||
|
* Used to set the std::allocator base class to
|
||||||
|
* __gnu_cxx::new_allocator.
|
||||||
|
*
|
||||||
|
* @tparam _Tp Type of allocated object.
|
||||||
|
*/
|
||||||
|
template<typename _Tp>
|
||||||
|
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Define new_allocator as the base class to std::allocator.
|
||||||
|
# define __allocator_base __gnu_cxx::new_allocator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Underlying io library details -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++io.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// c_io_stdio.h - Defines for using "C" stdio.h
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_IO_H
|
||||||
|
#define _GLIBCXX_CXX_IO_H 1
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef __gthread_mutex_t __c_lock;
|
||||||
|
|
||||||
|
// for basic_file.h
|
||||||
|
typedef FILE __c_file;
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// Wrapper for underlying C-language localization -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++locale.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.8 Standard locale categories.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_LOCALE_H
|
||||||
|
#define _GLIBCXX_CXX_LOCALE_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <clocale>
|
||||||
|
|
||||||
|
#define _GLIBCXX_NUM_CATEGORIES 0
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef int* __c_locale;
|
||||||
|
|
||||||
|
// Convert numeric value of type double and long double to string and
|
||||||
|
// return length of string. If vsnprintf is available use it, otherwise
|
||||||
|
// fall back to the unsafe vsprintf which, in general, can be dangerous
|
||||||
|
// and should be avoided.
|
||||||
|
inline int
|
||||||
|
__convert_from_v(const __c_locale&, char* __out,
|
||||||
|
const int __size __attribute__((__unused__)),
|
||||||
|
const char* __fmt, ...)
|
||||||
|
{
|
||||||
|
char* __old = std::setlocale(LC_NUMERIC, 0);
|
||||||
|
char* __sav = 0;
|
||||||
|
if (__builtin_strcmp(__old, "C"))
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__old) + 1;
|
||||||
|
__sav = new char[__len];
|
||||||
|
__builtin_memcpy(__sav, __old, __len);
|
||||||
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
}
|
||||||
|
|
||||||
|
__builtin_va_list __args;
|
||||||
|
__builtin_va_start(__args, __fmt);
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_USE_C99
|
||||||
|
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
|
||||||
|
#else
|
||||||
|
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__builtin_va_end(__args);
|
||||||
|
|
||||||
|
if (__sav)
|
||||||
|
{
|
||||||
|
std::setlocale(LC_NUMERIC, __sav);
|
||||||
|
delete [] __sav;
|
||||||
|
}
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2005-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cpu_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CPU_DEFINES
|
||||||
|
#define _GLIBCXX_CPU_DEFINES 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
|
||||||
|
|
||||||
|
// Support for Solaris 2.5.1
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
/// @brief Base class for ctype.
|
||||||
|
struct ctype_base
|
||||||
|
{
|
||||||
|
// Non-standard typedefs.
|
||||||
|
typedef const int* __to_type;
|
||||||
|
|
||||||
|
// NB: Offsets into ctype<char>::_M_table force a particular size
|
||||||
|
// on the mask type. Because of this, we don't use an enum.
|
||||||
|
typedef char mask;
|
||||||
|
static const mask upper = _U;
|
||||||
|
static const mask lower = _L;
|
||||||
|
static const mask alpha = _U | _L;
|
||||||
|
static const mask digit = _N;
|
||||||
|
static const mask xdigit = _X | _N;
|
||||||
|
static const mask space = _S;
|
||||||
|
static const mask print = _P | _U | _L | _N | _B;
|
||||||
|
static const mask graph = _P | _U | _L | _N;
|
||||||
|
static const mask cntrl = _C;
|
||||||
|
static const mask punct = _P;
|
||||||
|
static const mask alnum = _U | _L | _N;
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/ctype_inline.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
|
||||||
|
// functions go in ctype.cc
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
bool
|
||||||
|
ctype<char>::
|
||||||
|
is(mask __m, char __c) const
|
||||||
|
{ return _M_table[static_cast<unsigned char>(__c)] & __m; }
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
is(const char* __low, const char* __high, mask* __vec) const
|
||||||
|
{
|
||||||
|
while (__low < __high)
|
||||||
|
*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
|
||||||
|
return __high;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_is(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && !this->is(__m, *__low))
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_not(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && this->is(__m, *__low) != 0)
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Control various target specific ABI tweaks. ARM version.
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cxxabi_tweaks.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{cxxabi.h}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CXXABI_TWEAKS_H
|
||||||
|
#define _CXXABI_TWEAKS_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace __cxxabiv1
|
||||||
|
{
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ARM_EABI__
|
||||||
|
// The ARM EABI uses the least significant bit of a 32-bit
|
||||||
|
// guard variable. */
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT 1
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
typedef int __guard;
|
||||||
|
|
||||||
|
// We also want the element size in array cookies.
|
||||||
|
#define _GLIBCXX_ELTSIZE_IN_COOKIE 1
|
||||||
|
|
||||||
|
// __cxa_vec_ctor should return a pointer to the array.
|
||||||
|
typedef void * __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x
|
||||||
|
// Constructors and destructors return the "this" pointer.
|
||||||
|
typedef void * __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#else // __ARM_EABI__
|
||||||
|
|
||||||
|
// The generic ABI uses the first byte of a 64-bit guard variable.
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
__extension__ typedef int __guard __attribute__((mode (__DI__)));
|
||||||
|
|
||||||
|
// __cxa_vec_ctor has void return type.
|
||||||
|
typedef void __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
|
||||||
|
// Constructors and destructors do not return a value.
|
||||||
|
typedef void __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#endif //!__ARM_EABI__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
} // namespace __cxxabiv1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/error_constants.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{system_error}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ERROR_CONSTANTS
|
||||||
|
#define _GLIBCXX_ERROR_CONSTANTS 1
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
enum class errc
|
||||||
|
{
|
||||||
|
address_family_not_supported = EAFNOSUPPORT,
|
||||||
|
address_in_use = EADDRINUSE,
|
||||||
|
address_not_available = EADDRNOTAVAIL,
|
||||||
|
already_connected = EISCONN,
|
||||||
|
argument_list_too_long = E2BIG,
|
||||||
|
argument_out_of_domain = EDOM,
|
||||||
|
bad_address = EFAULT,
|
||||||
|
bad_file_descriptor = EBADF,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EBADMSG
|
||||||
|
bad_message = EBADMSG,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
broken_pipe = EPIPE,
|
||||||
|
connection_aborted = ECONNABORTED,
|
||||||
|
connection_already_in_progress = EALREADY,
|
||||||
|
connection_refused = ECONNREFUSED,
|
||||||
|
connection_reset = ECONNRESET,
|
||||||
|
cross_device_link = EXDEV,
|
||||||
|
destination_address_required = EDESTADDRREQ,
|
||||||
|
device_or_resource_busy = EBUSY,
|
||||||
|
directory_not_empty = ENOTEMPTY,
|
||||||
|
executable_format_error = ENOEXEC,
|
||||||
|
file_exists = EEXIST,
|
||||||
|
file_too_large = EFBIG,
|
||||||
|
filename_too_long = ENAMETOOLONG,
|
||||||
|
function_not_supported = ENOSYS,
|
||||||
|
host_unreachable = EHOSTUNREACH,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EIDRM
|
||||||
|
identifier_removed = EIDRM,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
illegal_byte_sequence = EILSEQ,
|
||||||
|
inappropriate_io_control_operation = ENOTTY,
|
||||||
|
interrupted = EINTR,
|
||||||
|
invalid_argument = EINVAL,
|
||||||
|
invalid_seek = ESPIPE,
|
||||||
|
io_error = EIO,
|
||||||
|
is_a_directory = EISDIR,
|
||||||
|
message_size = EMSGSIZE,
|
||||||
|
network_down = ENETDOWN,
|
||||||
|
network_reset = ENETRESET,
|
||||||
|
network_unreachable = ENETUNREACH,
|
||||||
|
no_buffer_space = ENOBUFS,
|
||||||
|
no_child_process = ECHILD,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOLINK
|
||||||
|
no_link = ENOLINK,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_lock_available = ENOLCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENODATA
|
||||||
|
no_message_available = ENODATA,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_message = ENOMSG,
|
||||||
|
no_protocol_option = ENOPROTOOPT,
|
||||||
|
no_space_on_device = ENOSPC,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSR
|
||||||
|
no_stream_resources = ENOSR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_such_device_or_address = ENXIO,
|
||||||
|
no_such_device = ENODEV,
|
||||||
|
no_such_file_or_directory = ENOENT,
|
||||||
|
no_such_process = ESRCH,
|
||||||
|
not_a_directory = ENOTDIR,
|
||||||
|
not_a_socket = ENOTSOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSTR
|
||||||
|
not_a_stream = ENOSTR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
not_connected = ENOTCONN,
|
||||||
|
not_enough_memory = ENOMEM,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTSUP
|
||||||
|
not_supported = ENOTSUP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ECANCELED
|
||||||
|
operation_canceled = ECANCELED,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
operation_in_progress = EINPROGRESS,
|
||||||
|
operation_not_permitted = EPERM,
|
||||||
|
operation_not_supported = EOPNOTSUPP,
|
||||||
|
operation_would_block = EWOULDBLOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
|
||||||
|
owner_dead = EOWNERDEAD,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
permission_denied = EACCES,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EPROTO
|
||||||
|
protocol_error = EPROTO,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protocol_not_supported = EPROTONOSUPPORT,
|
||||||
|
read_only_file_system = EROFS,
|
||||||
|
resource_deadlock_would_occur = EDEADLK,
|
||||||
|
resource_unavailable_try_again = EAGAIN,
|
||||||
|
result_out_of_range = ERANGE,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
|
||||||
|
state_not_recoverable = ENOTRECOVERABLE,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETIME
|
||||||
|
stream_timeout = ETIME,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETXTBSY
|
||||||
|
text_file_busy = ETXTBSY,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
timed_out = ETIMEDOUT,
|
||||||
|
too_many_files_open_in_system = ENFILE,
|
||||||
|
too_many_files_open = EMFILE,
|
||||||
|
too_many_links = EMLINK,
|
||||||
|
too_many_symbolic_link_levels = ELOOP,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOVERFLOW
|
||||||
|
value_too_large = EOVERFLOW,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wrong_protocol_type = EPROTOTYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
// C++ includes used for precompiling extensions -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file extc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
|
#include <bits/stdtr1c++.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ext/algorithm>
|
||||||
|
#include <ext/array_allocator.h>
|
||||||
|
#include <ext/atomicity.h>
|
||||||
|
#include <ext/bitmap_allocator.h>
|
||||||
|
#include <ext/cast.h>
|
||||||
|
#include <ext/concurrence.h>
|
||||||
|
#include <ext/debug_allocator.h>
|
||||||
|
#include <ext/extptr_allocator.h>
|
||||||
|
#include <ext/functional>
|
||||||
|
#include <ext/iterator>
|
||||||
|
#include <ext/malloc_allocator.h>
|
||||||
|
#include <ext/memory>
|
||||||
|
#include <ext/mt_allocator.h>
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
#include <ext/numeric>
|
||||||
|
#include <ext/pod_char_traits.h>
|
||||||
|
#include <ext/pointer.h>
|
||||||
|
#include <ext/pool_allocator.h>
|
||||||
|
#include <ext/rb_tree>
|
||||||
|
#include <ext/rope>
|
||||||
|
#include <ext/slist>
|
||||||
|
#include <ext/stdio_filebuf.h>
|
||||||
|
#include <ext/stdio_sync_filebuf.h>
|
||||||
|
#include <ext/throw_allocator.h>
|
||||||
|
#include <ext/typelist.h>
|
||||||
|
#include <ext/type_traits.h>
|
||||||
|
#include <ext/vstring.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/priority_queue.hpp>
|
||||||
|
#include <ext/pb_ds/exception.hpp>
|
||||||
|
#include <ext/pb_ds/hash_policy.hpp>
|
||||||
|
#include <ext/pb_ds/list_update_policy.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
#include <ext/pb_ds/trie_policy.hpp>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ICONV
|
||||||
|
#include <ext/codecvt_specializations.h>
|
||||||
|
#include <ext/enc_filebuf.h>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,889 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
|
||||||
|
/* POSIX threads specific definitions.
|
||||||
|
Easy, since the interface is just one-to-one mapping. */
|
||||||
|
|
||||||
|
#define __GTHREADS 1
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|
||||||
|
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
|
||||||
|
# include <unistd.h>
|
||||||
|
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
|
||||||
|
# else
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef pthread_t __gthread_t;
|
||||||
|
typedef pthread_key_t __gthread_key_t;
|
||||||
|
typedef pthread_once_t __gthread_once_t;
|
||||||
|
typedef pthread_mutex_t __gthread_mutex_t;
|
||||||
|
typedef pthread_mutex_t __gthread_recursive_mutex_t;
|
||||||
|
typedef pthread_cond_t __gthread_cond_t;
|
||||||
|
typedef struct timespec __gthread_time_t;
|
||||||
|
|
||||||
|
/* POSIX like conditional variables are supported. Please look at comments
|
||||||
|
in gthr.h for details. */
|
||||||
|
#define __GTHREAD_HAS_COND 1
|
||||||
|
|
||||||
|
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
|
||||||
|
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
||||||
|
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||||
|
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||||
|
#else
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
|
||||||
|
#define __GTHREAD_TIME_INIT {0,0}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_MUTEX_INIT
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
# undef __GTHREAD_COND_INIT
|
||||||
|
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
# ifndef __gthrw_pragma
|
||||||
|
# define __gthrw_pragma(pragma)
|
||||||
|
# endif
|
||||||
|
# define __gthrw2(name,name2,type) \
|
||||||
|
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
|
||||||
|
__gthrw_pragma(weak type)
|
||||||
|
# define __gthrw_(name) __gthrw_ ## name
|
||||||
|
#else
|
||||||
|
# define __gthrw2(name,name2,type)
|
||||||
|
# define __gthrw_(name) name
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
|
||||||
|
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
|
||||||
|
|
||||||
|
__gthrw(pthread_once)
|
||||||
|
__gthrw(pthread_getspecific)
|
||||||
|
__gthrw(pthread_setspecific)
|
||||||
|
|
||||||
|
__gthrw(pthread_create)
|
||||||
|
__gthrw(pthread_join)
|
||||||
|
__gthrw(pthread_equal)
|
||||||
|
__gthrw(pthread_self)
|
||||||
|
__gthrw(pthread_detach)
|
||||||
|
#ifndef __BIONIC__
|
||||||
|
__gthrw(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
__gthrw(sched_yield)
|
||||||
|
|
||||||
|
__gthrw(pthread_mutex_lock)
|
||||||
|
__gthrw(pthread_mutex_trylock)
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
__gthrw(pthread_mutex_timedlock)
|
||||||
|
#endif
|
||||||
|
__gthrw(pthread_mutex_unlock)
|
||||||
|
__gthrw(pthread_mutex_init)
|
||||||
|
__gthrw(pthread_mutex_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_cond_init)
|
||||||
|
__gthrw(pthread_cond_broadcast)
|
||||||
|
__gthrw(pthread_cond_signal)
|
||||||
|
__gthrw(pthread_cond_wait)
|
||||||
|
__gthrw(pthread_cond_timedwait)
|
||||||
|
__gthrw(pthread_cond_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_key_create)
|
||||||
|
__gthrw(pthread_key_delete)
|
||||||
|
__gthrw(pthread_mutexattr_init)
|
||||||
|
__gthrw(pthread_mutexattr_settype)
|
||||||
|
__gthrw(pthread_mutexattr_destroy)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
|
||||||
|
/* Objective-C. */
|
||||||
|
__gthrw(pthread_exit)
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(sched_get_priority_max)
|
||||||
|
__gthrw(sched_get_priority_min)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
__gthrw(pthread_attr_destroy)
|
||||||
|
__gthrw(pthread_attr_init)
|
||||||
|
__gthrw(pthread_attr_setdetachstate)
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(pthread_getschedparam)
|
||||||
|
__gthrw(pthread_setschedparam)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
|
||||||
|
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
|
||||||
|
-pthreads is not specified. The functions are dummies and most return an
|
||||||
|
error value. However pthread_once returns 0 without invoking the routine
|
||||||
|
it is passed so we cannot pretend that the interface is active if -pthreads
|
||||||
|
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
|
||||||
|
we need to play the usual game with weak symbols. On Solaris 10 and up, a
|
||||||
|
working interface is always exposed. On FreeBSD 6 and later, libc also
|
||||||
|
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
|
||||||
|
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
|
||||||
|
which means the alternate __gthread_active_p below cannot be used there. */
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static void
|
||||||
|
__gthread_trigger (void)
|
||||||
|
{
|
||||||
|
__gthread_active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
|
||||||
|
/* This test is not protected to avoid taking a lock on the main code
|
||||||
|
path so every update of __gthread_active in a threaded program must
|
||||||
|
be atomic with regard to the result of the test. */
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_once))
|
||||||
|
{
|
||||||
|
/* If this really is a threaded program, then we must ensure that
|
||||||
|
__gthread_active has been set to 1 before exiting this block. */
|
||||||
|
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||||
|
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
|
||||||
|
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure we'll never enter this block again. */
|
||||||
|
if (__gthread_active < 0)
|
||||||
|
__gthread_active = 0;
|
||||||
|
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* neither FreeBSD nor Solaris */
|
||||||
|
|
||||||
|
/* For a program to be multi-threaded the only thing that it certainly must
|
||||||
|
be using is pthread_create. However, there may be other libraries that
|
||||||
|
intercept pthread_create with their own definitions to wrap pthreads
|
||||||
|
functionality for some purpose. In those cases, pthread_create being
|
||||||
|
defined might not necessarily mean that libpthread is actually linked
|
||||||
|
in.
|
||||||
|
|
||||||
|
For the GNU C library, we can use a known internal name. This is always
|
||||||
|
available in the ABI, but no other library would define it. That is
|
||||||
|
ideal, since any public pthread function might be intercepted just as
|
||||||
|
pthread_create might be. __pthread_key_create is an "internal"
|
||||||
|
implementation symbol, but it is part of the public exported ABI. Also,
|
||||||
|
it's among the symbols that the static libpthread.a always links in
|
||||||
|
whenever pthread_create is used, so there is no danger of a false
|
||||||
|
negative result in any statically-linked, multi-threaded program.
|
||||||
|
|
||||||
|
For others, we choose pthread_cancel as a function that seems unlikely
|
||||||
|
to be redefined by an interceptor library. The bionic (Android) C
|
||||||
|
library does not provide pthread_cancel, so we do use pthread_create
|
||||||
|
there (and interceptor libraries lose). */
|
||||||
|
|
||||||
|
#ifdef __GLIBC__
|
||||||
|
__gthrw2(__gthrw_(__pthread_key_create),
|
||||||
|
__pthread_key_create,
|
||||||
|
pthread_key_create)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
|
||||||
|
#elif defined (__BIONIC__)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
|
||||||
|
#else
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static void *const __gthread_active_ptr
|
||||||
|
= __extension__ (void *) >HR_ACTIVE_PROXY;
|
||||||
|
return __gthread_active_ptr != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FreeBSD or Solaris */
|
||||||
|
|
||||||
|
#else /* not __GXX_WEAK__ */
|
||||||
|
|
||||||
|
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
|
||||||
|
calls in shared flavors of the HP-UX C library. Most of the stubs
|
||||||
|
have no functionality. The details are described in the "libc cumulative
|
||||||
|
patch" for each subversion of HP-UX 11. There are two special interfaces
|
||||||
|
provided for checking whether an application is linked to a shared pthread
|
||||||
|
library or not. However, these interfaces aren't available in early
|
||||||
|
libpthread libraries. We also need a test that works for archive
|
||||||
|
libraries. We can't use pthread_once as some libc versions call the
|
||||||
|
init function. We also can't use pthread_create or pthread_attr_init
|
||||||
|
as these create a thread and thereby prevent changing the default stack
|
||||||
|
size. The function pthread_default_stacksize_np is available in both
|
||||||
|
the archive and shared versions of libpthread. It can be used to
|
||||||
|
determine the default pthread stack size. There is a stub in some
|
||||||
|
shared libc versions which returns a zero size if pthreads are not
|
||||||
|
active. We provide an equivalent stub to handle cases where libc
|
||||||
|
doesn't provide one. */
|
||||||
|
|
||||||
|
#if defined(__hppa__) && defined(__hpux__)
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
size_t __s;
|
||||||
|
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
pthread_default_stacksize_np (0, &__s);
|
||||||
|
__gthread_active = __s ? 1 : 0;
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* not hppa-hpux */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* hppa-hpux */
|
||||||
|
|
||||||
|
#endif /* __GXX_WEAK__ */
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* This is the config.h file in libobjc/ */
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
|
# include <sched.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Key structure for maintaining thread specific storage */
|
||||||
|
static pthread_key_t _objc_thread_storage;
|
||||||
|
static pthread_attr_t _objc_thread_attribs;
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
/* Initialize the thread storage key. */
|
||||||
|
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
|
||||||
|
{
|
||||||
|
/* The normal default detach state for threads is
|
||||||
|
* PTHREAD_CREATE_JOINABLE which causes threads to not die
|
||||||
|
* when you think they should. */
|
||||||
|
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
|
||||||
|
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
|
||||||
|
PTHREAD_CREATE_DETACHED) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
|
||||||
|
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
|
||||||
|
{
|
||||||
|
objc_thread_t thread_id;
|
||||||
|
pthread_t new_thread_handle;
|
||||||
|
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
|
||||||
|
(void *) func, arg)))
|
||||||
|
thread_id = (objc_thread_t) new_thread_handle;
|
||||||
|
else
|
||||||
|
thread_id = NULL;
|
||||||
|
|
||||||
|
return thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority)
|
||||||
|
{
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
pthread_t thread_id = __gthrw_(pthread_self) ();
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
int priority_min, priority_max;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
|
||||||
|
{
|
||||||
|
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (priority > priority_max)
|
||||||
|
priority = priority_max;
|
||||||
|
else if (priority < priority_min)
|
||||||
|
priority = priority_min;
|
||||||
|
params.sched_priority = priority;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The solaris 7 and several other man pages incorrectly state that
|
||||||
|
* this should be a pointer to policy but pthread.h is universally
|
||||||
|
* at odds with this.
|
||||||
|
*/
|
||||||
|
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
|
||||||
|
return params.sched_priority;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
/* exit the thread */
|
||||||
|
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
|
||||||
|
|
||||||
|
/* Failed if we reached here */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return (objc_thread_t) __gthrw_(pthread_self) ();
|
||||||
|
else
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
|
||||||
|
else
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Posix Threads specifically require that the thread be unlocked
|
||||||
|
* for __gthrw_(pthread_mutex_destroy) to work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
|
||||||
|
if (count < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while (count);
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
condition->backend = objc_malloc (sizeof (pthread_cond_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
|
||||||
|
(pthread_mutex_t *) mutex->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
|
||||||
|
void *__args)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_join (__gthread_t __threadid, void **__value_ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_join) (__threadid, __value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_detach (__gthread_t __threadid)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_detach) (__threadid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_equal) (__t1, __t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __gthread_t
|
||||||
|
__gthread_self (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_self) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_yield (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_once) (__once, __func);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_delete (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_delete) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_getspecific) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_mutex_init) (__mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|
||||||
|
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
pthread_mutexattr_t __attr;
|
||||||
|
int __r;
|
||||||
|
|
||||||
|
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
|
||||||
|
PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
|
||||||
|
return __r;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
static inline void
|
||||||
|
__gthread_cond_init_function (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_cond_init) (__cond, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_broadcast (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_broadcast) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_signal (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_signal) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
|
||||||
|
__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_cond_wait (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_destroy (__gthread_cond_t* __cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_destroy) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
/* Threads compatibility routines for libgcc2. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_H
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If this file is compiled with threads support, it must
|
||||||
|
#define __GTHREADS 1
|
||||||
|
to indicate that threads support is present. Also it has define
|
||||||
|
function
|
||||||
|
int __gthread_active_p ()
|
||||||
|
that returns 1 if thread system is active, 0 if not.
|
||||||
|
|
||||||
|
The threads interface must define the following types:
|
||||||
|
__gthread_key_t
|
||||||
|
__gthread_once_t
|
||||||
|
__gthread_mutex_t
|
||||||
|
__gthread_recursive_mutex_t
|
||||||
|
|
||||||
|
The threads interface must define the following macros:
|
||||||
|
|
||||||
|
__GTHREAD_ONCE_INIT
|
||||||
|
to initialize __gthread_once_t
|
||||||
|
__GTHREAD_MUTEX_INIT
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
__GTHREAD_MUTEX_INIT_FUNCTION
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
Define this to a function which looks like this:
|
||||||
|
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
|
||||||
|
Some systems can't initialize a mutex without a
|
||||||
|
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
as above, but for a recursive mutex.
|
||||||
|
|
||||||
|
The threads interface must define the following static functions:
|
||||||
|
|
||||||
|
int __gthread_once (__gthread_once_t *once, void (*func) ())
|
||||||
|
|
||||||
|
int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
|
||||||
|
int __gthread_key_delete (__gthread_key_t key)
|
||||||
|
|
||||||
|
void *__gthread_getspecific (__gthread_key_t key)
|
||||||
|
int __gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||||
|
|
||||||
|
int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_mutex_lock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
The following are supported in POSIX threads only. They are required to
|
||||||
|
fix a deadlock in static initialization inside libsupc++. The header file
|
||||||
|
gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
|
||||||
|
features are supported.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_cond_t
|
||||||
|
|
||||||
|
Macros:
|
||||||
|
__GTHREAD_COND_INIT
|
||||||
|
__GTHREAD_COND_INIT_FUNCTION
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_cond_broadcast (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
|
||||||
|
int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
||||||
|
__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
All functions returning int should return zero on success or the error
|
||||||
|
number. If the operation is not supported, -1 is returned.
|
||||||
|
|
||||||
|
If the following are also defined, you should
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
to enable the c++0x thread library.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_t
|
||||||
|
__gthread_time_t
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_create (__gthread_t *thread, void *(*func) (void*),
|
||||||
|
void *args);
|
||||||
|
int __gthread_join (__gthread_t thread, void **value_ptr);
|
||||||
|
int __gthread_detach (__gthread_t thread);
|
||||||
|
int __gthread_equal (__gthread_t t1, __gthread_t t2);
|
||||||
|
__gthread_t __gthread_self (void);
|
||||||
|
int __gthread_yield (void);
|
||||||
|
|
||||||
|
int __gthread_mutex_timedlock (__gthread_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_time);
|
||||||
|
|
||||||
|
int __gthread_cond_signal (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_timedwait (__gthread_cond_t *cond,
|
||||||
|
__gthread_mutex_t *mutex,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __GXX_WEAK__
|
||||||
|
/* The pe-coff weak support isn't fully compatible to ELF's weak.
|
||||||
|
For static libraries it might would work, but as we need to deal
|
||||||
|
with shared versions too, we disable it for mingw-targets. */
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#undef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include <bits/gthr-default.h>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_H */
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::messages implementation details, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/messages_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Non-virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(__c_locale, const char*, size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
|
||||||
|
const char*) const
|
||||||
|
{ return this->do_open(__s, __loc); }
|
||||||
|
|
||||||
|
// Virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::~messages()
|
||||||
|
{ _S_destroy_c_locale(_M_c_locale_messages); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::do_open(const basic_string<char>&, const locale&) const
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::string_type
|
||||||
|
messages<_CharT>::do_get(catalog, int, int,
|
||||||
|
const string_type& __dfault) const
|
||||||
|
{ return __dfault; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
void
|
||||||
|
messages<_CharT>::do_close(catalog) const
|
||||||
|
{ }
|
||||||
|
|
||||||
|
// messages_byname
|
||||||
|
template<typename _CharT>
|
||||||
|
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
|
||||||
|
: messages<_CharT>(__refs)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, "C") != 0
|
||||||
|
&& __builtin_strcmp(__s, "POSIX") != 0)
|
||||||
|
{
|
||||||
|
this->_S_destroy_c_locale(this->_M_c_locale_messages);
|
||||||
|
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number handling, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BITS_OPT_RANDOM_H
|
||||||
|
#define _BITS_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _BITS_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Specific definitions for newlib -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/os_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_OS_DEFINES
|
||||||
|
#define _GLIBCXX_OS_DEFINES 1
|
||||||
|
|
||||||
|
// System-specific #define, typedefs, corrections, etc, go here. This
|
||||||
|
// file will come before all others.
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
|
||||||
|
#if defined (_GLIBCXX_DLL)
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default __attribute__ ((__dllimport__))
|
||||||
|
#else
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default
|
||||||
|
#endif
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_hidden
|
||||||
|
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY_ ## V
|
||||||
|
|
||||||
|
// See libstdc++/20806.
|
||||||
|
#define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
// C++ includes used for precompiling -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 17.4.1.2 Headers
|
||||||
|
|
||||||
|
// C
|
||||||
|
#ifndef _GLIBCXX_NO_ASSERT
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
#include <cctype>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <ciso646>
|
||||||
|
#include <climits>
|
||||||
|
#include <clocale>
|
||||||
|
#include <cmath>
|
||||||
|
#include <csetjmp>
|
||||||
|
#include <csignal>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <ccomplex>
|
||||||
|
#include <cfenv>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstdalign>
|
||||||
|
#include <cstdbool>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ctgmath>
|
||||||
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++
|
||||||
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <complex>
|
||||||
|
#include <deque>
|
||||||
|
#include <exception>
|
||||||
|
#include <fstream>
|
||||||
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <list>
|
||||||
|
#include <locale>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <new>
|
||||||
|
#include <numeric>
|
||||||
|
#include <ostream>
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stack>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <utility>
|
||||||
|
#include <valarray>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <array>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <forward_list>
|
||||||
|
#include <future>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <mutex>
|
||||||
|
#include <random>
|
||||||
|
#include <ratio>
|
||||||
|
#include <regex>
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <system_error>
|
||||||
|
#include <thread>
|
||||||
|
#include <tuple>
|
||||||
|
#include <typeindex>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
// C++ includes used for precompiling TR1 -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdtr1c++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
#include <tr1/array>
|
||||||
|
#include <tr1/cctype>
|
||||||
|
#include <tr1/cfenv>
|
||||||
|
#include <tr1/cfloat>
|
||||||
|
#include <tr1/cinttypes>
|
||||||
|
#include <tr1/climits>
|
||||||
|
#include <tr1/cmath>
|
||||||
|
#include <tr1/complex>
|
||||||
|
#include <tr1/cstdarg>
|
||||||
|
#include <tr1/cstdbool>
|
||||||
|
#include <tr1/cstdint>
|
||||||
|
#include <tr1/cstdio>
|
||||||
|
#include <tr1/cstdlib>
|
||||||
|
#include <tr1/ctgmath>
|
||||||
|
#include <tr1/ctime>
|
||||||
|
#include <tr1/cwchar>
|
||||||
|
#include <tr1/cwctype>
|
||||||
|
#include <tr1/functional>
|
||||||
|
#include <tr1/random>
|
||||||
|
#include <tr1/tuple>
|
||||||
|
#include <tr1/unordered_map>
|
||||||
|
#include <tr1/unordered_set>
|
||||||
|
#include <tr1/utility>
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/time_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.5.1.2 - time_get functions
|
||||||
|
// ISO C++ 14882: 22.2.5.3.2 - time_put functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
|
||||||
|
: facet(__refs), _M_data(__cache)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
|
||||||
|
size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__s) + 1;
|
||||||
|
char* __tmp = new char[__len];
|
||||||
|
__builtin_memcpy(__tmp, __s, __len);
|
||||||
|
_M_name_timepunct = __tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
|
||||||
|
__try
|
||||||
|
{ _M_initialize_timepunct(__cloc); }
|
||||||
|
__catch(...)
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
__throw_exception_again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::~__timepunct()
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
delete _M_data;
|
||||||
|
_S_destroy_c_locale(_M_c_locale_timepunct);
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number extensions, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file ext/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ext/random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EXT_OPT_RANDOM_H
|
||||||
|
#define _EXT_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _EXT_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Low-level type for atomic operations -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file atomic_word.h
|
||||||
|
* This file is a GNU extension to the Standard C++ Library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ATOMIC_WORD_H
|
||||||
|
#define _GLIBCXX_ATOMIC_WORD_H 1
|
||||||
|
|
||||||
|
typedef int _Atomic_word;
|
||||||
|
|
||||||
|
// Define these two macros using the appropriate memory barrier for the target.
|
||||||
|
// The commented out versions below are the defaults.
|
||||||
|
// See ia64/atomic_word.h for an alternative approach.
|
||||||
|
|
||||||
|
// This one prevents loads from being hoisted across the barrier;
|
||||||
|
// in other words, this is a Load-Load acquire barrier.
|
||||||
|
// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h.
|
||||||
|
// #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
// This one prevents stores from being sunk across the barrier; in other
|
||||||
|
// words, a Store-Store release barrier.
|
||||||
|
// #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
// Wrapper of C-language FILE struct -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 27.8 File-based streams
|
||||||
|
//
|
||||||
|
|
||||||
|
/** @file bits/basic_file.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
|
||||||
|
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <bits/c++io.h> // for __c_lock and __c_file
|
||||||
|
#include <ios>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Generic declaration.
|
||||||
|
template<typename _CharT>
|
||||||
|
class __basic_file;
|
||||||
|
|
||||||
|
// Specialization.
|
||||||
|
template<>
|
||||||
|
class __basic_file<char>
|
||||||
|
{
|
||||||
|
// Underlying data source/sink.
|
||||||
|
__c_file* _M_cfile;
|
||||||
|
|
||||||
|
// True iff we opened _M_cfile, and thus must close it ourselves.
|
||||||
|
bool _M_cfile_created;
|
||||||
|
|
||||||
|
public:
|
||||||
|
__basic_file(__c_lock* __lock = 0) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(__c_file* __file, ios_base::openmode);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(int __fd, ios_base::openmode __mode) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
close();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE bool
|
||||||
|
is_open() const throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE int
|
||||||
|
fd() throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE __c_file*
|
||||||
|
file() throw ();
|
||||||
|
|
||||||
|
~__basic_file();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn(const char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn_2(const char* __s1, streamsize __n1,
|
||||||
|
const char* __s2, streamsize __n2);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsgetn(char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamoff
|
||||||
|
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
|
||||||
|
|
||||||
|
int
|
||||||
|
sync();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
showmanyc();
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
// Base to std::allocator -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++allocator.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{memory}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
|
||||||
|
#define _GLIBCXX_CXX_ALLOCATOR_H 1
|
||||||
|
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief An alias to the base class for std::allocator.
|
||||||
|
* @ingroup allocators
|
||||||
|
*
|
||||||
|
* Used to set the std::allocator base class to
|
||||||
|
* __gnu_cxx::new_allocator.
|
||||||
|
*
|
||||||
|
* @tparam _Tp Type of allocated object.
|
||||||
|
*/
|
||||||
|
template<typename _Tp>
|
||||||
|
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Define new_allocator as the base class to std::allocator.
|
||||||
|
# define __allocator_base __gnu_cxx::new_allocator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Underlying io library details -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++io.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// c_io_stdio.h - Defines for using "C" stdio.h
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_IO_H
|
||||||
|
#define _GLIBCXX_CXX_IO_H 1
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef __gthread_mutex_t __c_lock;
|
||||||
|
|
||||||
|
// for basic_file.h
|
||||||
|
typedef FILE __c_file;
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// Wrapper for underlying C-language localization -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++locale.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.8 Standard locale categories.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_LOCALE_H
|
||||||
|
#define _GLIBCXX_CXX_LOCALE_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <clocale>
|
||||||
|
|
||||||
|
#define _GLIBCXX_NUM_CATEGORIES 0
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef int* __c_locale;
|
||||||
|
|
||||||
|
// Convert numeric value of type double and long double to string and
|
||||||
|
// return length of string. If vsnprintf is available use it, otherwise
|
||||||
|
// fall back to the unsafe vsprintf which, in general, can be dangerous
|
||||||
|
// and should be avoided.
|
||||||
|
inline int
|
||||||
|
__convert_from_v(const __c_locale&, char* __out,
|
||||||
|
const int __size __attribute__((__unused__)),
|
||||||
|
const char* __fmt, ...)
|
||||||
|
{
|
||||||
|
char* __old = std::setlocale(LC_NUMERIC, 0);
|
||||||
|
char* __sav = 0;
|
||||||
|
if (__builtin_strcmp(__old, "C"))
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__old) + 1;
|
||||||
|
__sav = new char[__len];
|
||||||
|
__builtin_memcpy(__sav, __old, __len);
|
||||||
|
std::setlocale(LC_NUMERIC, "C");
|
||||||
|
}
|
||||||
|
|
||||||
|
__builtin_va_list __args;
|
||||||
|
__builtin_va_start(__args, __fmt);
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_USE_C99
|
||||||
|
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
|
||||||
|
#else
|
||||||
|
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__builtin_va_end(__args);
|
||||||
|
|
||||||
|
if (__sav)
|
||||||
|
{
|
||||||
|
std::setlocale(LC_NUMERIC, __sav);
|
||||||
|
delete [] __sav;
|
||||||
|
}
|
||||||
|
return __ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2005-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cpu_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CPU_DEFINES
|
||||||
|
#define _GLIBCXX_CPU_DEFINES 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
|
||||||
|
|
||||||
|
// Support for Solaris 2.5.1
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
/// @brief Base class for ctype.
|
||||||
|
struct ctype_base
|
||||||
|
{
|
||||||
|
// Non-standard typedefs.
|
||||||
|
typedef const int* __to_type;
|
||||||
|
|
||||||
|
// NB: Offsets into ctype<char>::_M_table force a particular size
|
||||||
|
// on the mask type. Because of this, we don't use an enum.
|
||||||
|
typedef char mask;
|
||||||
|
static const mask upper = _U;
|
||||||
|
static const mask lower = _L;
|
||||||
|
static const mask alpha = _U | _L;
|
||||||
|
static const mask digit = _N;
|
||||||
|
static const mask xdigit = _X | _N;
|
||||||
|
static const mask space = _S;
|
||||||
|
static const mask print = _P | _U | _L | _N | _B;
|
||||||
|
static const mask graph = _P | _U | _L | _N;
|
||||||
|
static const mask cntrl = _C;
|
||||||
|
static const mask punct = _P;
|
||||||
|
static const mask alnum = _U | _L | _N;
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
// Locale support -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/ctype_inline.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.1 Locales
|
||||||
|
//
|
||||||
|
|
||||||
|
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
|
||||||
|
// functions go in ctype.cc
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
bool
|
||||||
|
ctype<char>::
|
||||||
|
is(mask __m, char __c) const
|
||||||
|
{ return _M_table[static_cast<unsigned char>(__c)] & __m; }
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
is(const char* __low, const char* __high, mask* __vec) const
|
||||||
|
{
|
||||||
|
while (__low < __high)
|
||||||
|
*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
|
||||||
|
return __high;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_is(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && !this->is(__m, *__low))
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
ctype<char>::
|
||||||
|
scan_not(mask __m, const char* __low, const char* __high) const
|
||||||
|
{
|
||||||
|
while (__low < __high && this->is(__m, *__low) != 0)
|
||||||
|
++__low;
|
||||||
|
return __low;
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Control various target specific ABI tweaks. ARM version.
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/cxxabi_tweaks.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{cxxabi.h}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CXXABI_TWEAKS_H
|
||||||
|
#define _CXXABI_TWEAKS_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
namespace __cxxabiv1
|
||||||
|
{
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ARM_EABI__
|
||||||
|
// The ARM EABI uses the least significant bit of a 32-bit
|
||||||
|
// guard variable. */
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) ((*(x) & 1) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT 1
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
typedef int __guard;
|
||||||
|
|
||||||
|
// We also want the element size in array cookies.
|
||||||
|
#define _GLIBCXX_ELTSIZE_IN_COOKIE 1
|
||||||
|
|
||||||
|
// __cxa_vec_ctor should return a pointer to the array.
|
||||||
|
typedef void * __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return x
|
||||||
|
// Constructors and destructors return the "this" pointer.
|
||||||
|
typedef void * __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#else // __ARM_EABI__
|
||||||
|
|
||||||
|
// The generic ABI uses the first byte of a 64-bit guard variable.
|
||||||
|
#define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0)
|
||||||
|
#define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1
|
||||||
|
#define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1)
|
||||||
|
#define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1)
|
||||||
|
#define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1)
|
||||||
|
__extension__ typedef int __guard __attribute__((mode (__DI__)));
|
||||||
|
|
||||||
|
// __cxa_vec_ctor has void return type.
|
||||||
|
typedef void __cxa_vec_ctor_return_type;
|
||||||
|
#define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return
|
||||||
|
// Constructors and destructors do not return a value.
|
||||||
|
typedef void __cxa_cdtor_return_type;
|
||||||
|
|
||||||
|
#endif //!__ARM_EABI__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
} // namespace __cxxabiv1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
// Specific definitions for generic platforms -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2007-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/error_constants.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{system_error}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ERROR_CONSTANTS
|
||||||
|
#define _GLIBCXX_ERROR_CONSTANTS 1
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <cerrno>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
enum class errc
|
||||||
|
{
|
||||||
|
address_family_not_supported = EAFNOSUPPORT,
|
||||||
|
address_in_use = EADDRINUSE,
|
||||||
|
address_not_available = EADDRNOTAVAIL,
|
||||||
|
already_connected = EISCONN,
|
||||||
|
argument_list_too_long = E2BIG,
|
||||||
|
argument_out_of_domain = EDOM,
|
||||||
|
bad_address = EFAULT,
|
||||||
|
bad_file_descriptor = EBADF,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EBADMSG
|
||||||
|
bad_message = EBADMSG,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
broken_pipe = EPIPE,
|
||||||
|
connection_aborted = ECONNABORTED,
|
||||||
|
connection_already_in_progress = EALREADY,
|
||||||
|
connection_refused = ECONNREFUSED,
|
||||||
|
connection_reset = ECONNRESET,
|
||||||
|
cross_device_link = EXDEV,
|
||||||
|
destination_address_required = EDESTADDRREQ,
|
||||||
|
device_or_resource_busy = EBUSY,
|
||||||
|
directory_not_empty = ENOTEMPTY,
|
||||||
|
executable_format_error = ENOEXEC,
|
||||||
|
file_exists = EEXIST,
|
||||||
|
file_too_large = EFBIG,
|
||||||
|
filename_too_long = ENAMETOOLONG,
|
||||||
|
function_not_supported = ENOSYS,
|
||||||
|
host_unreachable = EHOSTUNREACH,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EIDRM
|
||||||
|
identifier_removed = EIDRM,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
illegal_byte_sequence = EILSEQ,
|
||||||
|
inappropriate_io_control_operation = ENOTTY,
|
||||||
|
interrupted = EINTR,
|
||||||
|
invalid_argument = EINVAL,
|
||||||
|
invalid_seek = ESPIPE,
|
||||||
|
io_error = EIO,
|
||||||
|
is_a_directory = EISDIR,
|
||||||
|
message_size = EMSGSIZE,
|
||||||
|
network_down = ENETDOWN,
|
||||||
|
network_reset = ENETRESET,
|
||||||
|
network_unreachable = ENETUNREACH,
|
||||||
|
no_buffer_space = ENOBUFS,
|
||||||
|
no_child_process = ECHILD,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOLINK
|
||||||
|
no_link = ENOLINK,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_lock_available = ENOLCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENODATA
|
||||||
|
no_message_available = ENODATA,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_message = ENOMSG,
|
||||||
|
no_protocol_option = ENOPROTOOPT,
|
||||||
|
no_space_on_device = ENOSPC,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSR
|
||||||
|
no_stream_resources = ENOSR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
no_such_device_or_address = ENXIO,
|
||||||
|
no_such_device = ENODEV,
|
||||||
|
no_such_file_or_directory = ENOENT,
|
||||||
|
no_such_process = ESRCH,
|
||||||
|
not_a_directory = ENOTDIR,
|
||||||
|
not_a_socket = ENOTSOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOSTR
|
||||||
|
not_a_stream = ENOSTR,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
not_connected = ENOTCONN,
|
||||||
|
not_enough_memory = ENOMEM,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTSUP
|
||||||
|
not_supported = ENOTSUP,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ECANCELED
|
||||||
|
operation_canceled = ECANCELED,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
operation_in_progress = EINPROGRESS,
|
||||||
|
operation_not_permitted = EPERM,
|
||||||
|
operation_not_supported = EOPNOTSUPP,
|
||||||
|
operation_would_block = EWOULDBLOCK,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOWNERDEAD
|
||||||
|
owner_dead = EOWNERDEAD,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
permission_denied = EACCES,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EPROTO
|
||||||
|
protocol_error = EPROTO,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protocol_not_supported = EPROTONOSUPPORT,
|
||||||
|
read_only_file_system = EROFS,
|
||||||
|
resource_deadlock_would_occur = EDEADLK,
|
||||||
|
resource_unavailable_try_again = EAGAIN,
|
||||||
|
result_out_of_range = ERANGE,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ENOTRECOVERABLE
|
||||||
|
state_not_recoverable = ENOTRECOVERABLE,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETIME
|
||||||
|
stream_timeout = ETIME,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ETXTBSY
|
||||||
|
text_file_busy = ETXTBSY,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
timed_out = ETIMEDOUT,
|
||||||
|
too_many_files_open_in_system = ENFILE,
|
||||||
|
too_many_files_open = EMFILE,
|
||||||
|
too_many_links = EMLINK,
|
||||||
|
too_many_symbolic_link_levels = ELOOP,
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_EOVERFLOW
|
||||||
|
value_too_large = EOVERFLOW,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wrong_protocol_type = EPROTOTYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
// C++ includes used for precompiling extensions -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file extc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __cplusplus < 201103L
|
||||||
|
#include <bits/stdtr1c++.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ext/algorithm>
|
||||||
|
#include <ext/array_allocator.h>
|
||||||
|
#include <ext/atomicity.h>
|
||||||
|
#include <ext/bitmap_allocator.h>
|
||||||
|
#include <ext/cast.h>
|
||||||
|
#include <ext/concurrence.h>
|
||||||
|
#include <ext/debug_allocator.h>
|
||||||
|
#include <ext/extptr_allocator.h>
|
||||||
|
#include <ext/functional>
|
||||||
|
#include <ext/iterator>
|
||||||
|
#include <ext/malloc_allocator.h>
|
||||||
|
#include <ext/memory>
|
||||||
|
#include <ext/mt_allocator.h>
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
#include <ext/numeric>
|
||||||
|
#include <ext/pod_char_traits.h>
|
||||||
|
#include <ext/pointer.h>
|
||||||
|
#include <ext/pool_allocator.h>
|
||||||
|
#include <ext/rb_tree>
|
||||||
|
#include <ext/rope>
|
||||||
|
#include <ext/slist>
|
||||||
|
#include <ext/stdio_filebuf.h>
|
||||||
|
#include <ext/stdio_sync_filebuf.h>
|
||||||
|
#include <ext/throw_allocator.h>
|
||||||
|
#include <ext/typelist.h>
|
||||||
|
#include <ext/type_traits.h>
|
||||||
|
#include <ext/vstring.h>
|
||||||
|
#include <ext/pb_ds/assoc_container.hpp>
|
||||||
|
#include <ext/pb_ds/priority_queue.hpp>
|
||||||
|
#include <ext/pb_ds/exception.hpp>
|
||||||
|
#include <ext/pb_ds/hash_policy.hpp>
|
||||||
|
#include <ext/pb_ds/list_update_policy.hpp>
|
||||||
|
#include <ext/pb_ds/tree_policy.hpp>
|
||||||
|
#include <ext/pb_ds/trie_policy.hpp>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_ICONV
|
||||||
|
#include <ext/codecvt_specializations.h>
|
||||||
|
#include <ext/enc_filebuf.h>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,889 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_POSIX_H
|
||||||
|
|
||||||
|
/* POSIX threads specific definitions.
|
||||||
|
Easy, since the interface is just one-to-one mapping. */
|
||||||
|
|
||||||
|
#define __GTHREADS 1
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \
|
||||||
|
|| !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK))
|
||||||
|
# include <unistd.h>
|
||||||
|
# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
|
||||||
|
# else
|
||||||
|
# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef pthread_t __gthread_t;
|
||||||
|
typedef pthread_key_t __gthread_key_t;
|
||||||
|
typedef pthread_once_t __gthread_once_t;
|
||||||
|
typedef pthread_mutex_t __gthread_mutex_t;
|
||||||
|
typedef pthread_mutex_t __gthread_recursive_mutex_t;
|
||||||
|
typedef pthread_cond_t __gthread_cond_t;
|
||||||
|
typedef struct timespec __gthread_time_t;
|
||||||
|
|
||||||
|
/* POSIX like conditional variables are supported. Please look at comments
|
||||||
|
in gthr.h for details. */
|
||||||
|
#define __GTHREAD_HAS_COND 1
|
||||||
|
|
||||||
|
#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
|
||||||
|
#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
||||||
|
#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
|
||||||
|
#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
||||||
|
#else
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
|
||||||
|
#define __GTHREAD_TIME_INIT {0,0}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_MUTEX_INIT
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
|
||||||
|
#endif
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
# undef __GTHREAD_COND_INIT
|
||||||
|
# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
# ifndef __gthrw_pragma
|
||||||
|
# define __gthrw_pragma(pragma)
|
||||||
|
# endif
|
||||||
|
# define __gthrw2(name,name2,type) \
|
||||||
|
static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
|
||||||
|
__gthrw_pragma(weak type)
|
||||||
|
# define __gthrw_(name) __gthrw_ ## name
|
||||||
|
#else
|
||||||
|
# define __gthrw2(name,name2,type)
|
||||||
|
# define __gthrw_(name) name
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
|
||||||
|
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
|
||||||
|
|
||||||
|
__gthrw(pthread_once)
|
||||||
|
__gthrw(pthread_getspecific)
|
||||||
|
__gthrw(pthread_setspecific)
|
||||||
|
|
||||||
|
__gthrw(pthread_create)
|
||||||
|
__gthrw(pthread_join)
|
||||||
|
__gthrw(pthread_equal)
|
||||||
|
__gthrw(pthread_self)
|
||||||
|
__gthrw(pthread_detach)
|
||||||
|
#ifndef __BIONIC__
|
||||||
|
__gthrw(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
__gthrw(sched_yield)
|
||||||
|
|
||||||
|
__gthrw(pthread_mutex_lock)
|
||||||
|
__gthrw(pthread_mutex_trylock)
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
__gthrw(pthread_mutex_timedlock)
|
||||||
|
#endif
|
||||||
|
__gthrw(pthread_mutex_unlock)
|
||||||
|
__gthrw(pthread_mutex_init)
|
||||||
|
__gthrw(pthread_mutex_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_cond_init)
|
||||||
|
__gthrw(pthread_cond_broadcast)
|
||||||
|
__gthrw(pthread_cond_signal)
|
||||||
|
__gthrw(pthread_cond_wait)
|
||||||
|
__gthrw(pthread_cond_timedwait)
|
||||||
|
__gthrw(pthread_cond_destroy)
|
||||||
|
|
||||||
|
__gthrw(pthread_key_create)
|
||||||
|
__gthrw(pthread_key_delete)
|
||||||
|
__gthrw(pthread_mutexattr_init)
|
||||||
|
__gthrw(pthread_mutexattr_settype)
|
||||||
|
__gthrw(pthread_mutexattr_destroy)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
|
||||||
|
/* Objective-C. */
|
||||||
|
__gthrw(pthread_exit)
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(sched_get_priority_max)
|
||||||
|
__gthrw(sched_get_priority_min)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
__gthrw(pthread_attr_destroy)
|
||||||
|
__gthrw(pthread_attr_init)
|
||||||
|
__gthrw(pthread_attr_setdetachstate)
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
__gthrw(pthread_getschedparam)
|
||||||
|
__gthrw(pthread_setschedparam)
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _LIBOBJC || _LIBOBJC_WEAK */
|
||||||
|
|
||||||
|
#if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
|
||||||
|
/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if
|
||||||
|
-pthreads is not specified. The functions are dummies and most return an
|
||||||
|
error value. However pthread_once returns 0 without invoking the routine
|
||||||
|
it is passed so we cannot pretend that the interface is active if -pthreads
|
||||||
|
is not specified. On Solaris 2.5.1, the interface is not exposed at all so
|
||||||
|
we need to play the usual game with weak symbols. On Solaris 10 and up, a
|
||||||
|
working interface is always exposed. On FreeBSD 6 and later, libc also
|
||||||
|
exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up
|
||||||
|
to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc,
|
||||||
|
which means the alternate __gthread_active_p below cannot be used there. */
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__))
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static void
|
||||||
|
__gthread_trigger (void)
|
||||||
|
{
|
||||||
|
__gthread_active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
|
||||||
|
/* This test is not protected to avoid taking a lock on the main code
|
||||||
|
path so every update of __gthread_active in a threaded program must
|
||||||
|
be atomic with regard to the result of the test. */
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_once))
|
||||||
|
{
|
||||||
|
/* If this really is a threaded program, then we must ensure that
|
||||||
|
__gthread_active has been set to 1 before exiting this block. */
|
||||||
|
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||||
|
__gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger);
|
||||||
|
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure we'll never enter this block again. */
|
||||||
|
if (__gthread_active < 0)
|
||||||
|
__gthread_active = 0;
|
||||||
|
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* neither FreeBSD nor Solaris */
|
||||||
|
|
||||||
|
/* For a program to be multi-threaded the only thing that it certainly must
|
||||||
|
be using is pthread_create. However, there may be other libraries that
|
||||||
|
intercept pthread_create with their own definitions to wrap pthreads
|
||||||
|
functionality for some purpose. In those cases, pthread_create being
|
||||||
|
defined might not necessarily mean that libpthread is actually linked
|
||||||
|
in.
|
||||||
|
|
||||||
|
For the GNU C library, we can use a known internal name. This is always
|
||||||
|
available in the ABI, but no other library would define it. That is
|
||||||
|
ideal, since any public pthread function might be intercepted just as
|
||||||
|
pthread_create might be. __pthread_key_create is an "internal"
|
||||||
|
implementation symbol, but it is part of the public exported ABI. Also,
|
||||||
|
it's among the symbols that the static libpthread.a always links in
|
||||||
|
whenever pthread_create is used, so there is no danger of a false
|
||||||
|
negative result in any statically-linked, multi-threaded program.
|
||||||
|
|
||||||
|
For others, we choose pthread_cancel as a function that seems unlikely
|
||||||
|
to be redefined by an interceptor library. The bionic (Android) C
|
||||||
|
library does not provide pthread_cancel, so we do use pthread_create
|
||||||
|
there (and interceptor libraries lose). */
|
||||||
|
|
||||||
|
#ifdef __GLIBC__
|
||||||
|
__gthrw2(__gthrw_(__pthread_key_create),
|
||||||
|
__pthread_key_create,
|
||||||
|
pthread_key_create)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create)
|
||||||
|
#elif defined (__BIONIC__)
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_create)
|
||||||
|
#else
|
||||||
|
# define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
static void *const __gthread_active_ptr
|
||||||
|
= __extension__ (void *) >HR_ACTIVE_PROXY;
|
||||||
|
return __gthread_active_ptr != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* FreeBSD or Solaris */
|
||||||
|
|
||||||
|
#else /* not __GXX_WEAK__ */
|
||||||
|
|
||||||
|
/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread
|
||||||
|
calls in shared flavors of the HP-UX C library. Most of the stubs
|
||||||
|
have no functionality. The details are described in the "libc cumulative
|
||||||
|
patch" for each subversion of HP-UX 11. There are two special interfaces
|
||||||
|
provided for checking whether an application is linked to a shared pthread
|
||||||
|
library or not. However, these interfaces aren't available in early
|
||||||
|
libpthread libraries. We also need a test that works for archive
|
||||||
|
libraries. We can't use pthread_once as some libc versions call the
|
||||||
|
init function. We also can't use pthread_create or pthread_attr_init
|
||||||
|
as these create a thread and thereby prevent changing the default stack
|
||||||
|
size. The function pthread_default_stacksize_np is available in both
|
||||||
|
the archive and shared versions of libpthread. It can be used to
|
||||||
|
determine the default pthread stack size. There is a stub in some
|
||||||
|
shared libc versions which returns a zero size if pthreads are not
|
||||||
|
active. We provide an equivalent stub to handle cases where libc
|
||||||
|
doesn't provide one. */
|
||||||
|
|
||||||
|
#if defined(__hppa__) && defined(__hpux__)
|
||||||
|
|
||||||
|
static volatile int __gthread_active = -1;
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
/* Avoid reading __gthread_active twice on the main code path. */
|
||||||
|
int __gthread_active_latest_value = __gthread_active;
|
||||||
|
size_t __s;
|
||||||
|
|
||||||
|
if (__builtin_expect (__gthread_active_latest_value < 0, 0))
|
||||||
|
{
|
||||||
|
pthread_default_stacksize_np (0, &__s);
|
||||||
|
__gthread_active = __s ? 1 : 0;
|
||||||
|
__gthread_active_latest_value = __gthread_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __gthread_active_latest_value != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* not hppa-hpux */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* hppa-hpux */
|
||||||
|
|
||||||
|
#endif /* __GXX_WEAK__ */
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* This is the config.h file in libobjc/ */
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SCHED_H
|
||||||
|
# include <sched.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Key structure for maintaining thread specific storage */
|
||||||
|
static pthread_key_t _objc_thread_storage;
|
||||||
|
static pthread_attr_t _objc_thread_attribs;
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
/* Initialize the thread storage key. */
|
||||||
|
if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0)
|
||||||
|
{
|
||||||
|
/* The normal default detach state for threads is
|
||||||
|
* PTHREAD_CREATE_JOINABLE which causes threads to not die
|
||||||
|
* when you think they should. */
|
||||||
|
if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0
|
||||||
|
&& __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs,
|
||||||
|
PTHREAD_CREATE_DETACHED) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0
|
||||||
|
&& __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (*func)(void *), void *arg)
|
||||||
|
{
|
||||||
|
objc_thread_t thread_id;
|
||||||
|
pthread_t new_thread_handle;
|
||||||
|
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs,
|
||||||
|
(void *) func, arg)))
|
||||||
|
thread_id = (objc_thread_t) new_thread_handle;
|
||||||
|
else
|
||||||
|
thread_id = NULL;
|
||||||
|
|
||||||
|
return thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority)
|
||||||
|
{
|
||||||
|
if (!__gthread_active_p ())
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
pthread_t thread_id = __gthrw_(pthread_self) ();
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
int priority_min, priority_max;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0)
|
||||||
|
{
|
||||||
|
if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (priority > priority_max)
|
||||||
|
priority = priority_max;
|
||||||
|
else if (priority < priority_min)
|
||||||
|
priority = priority_min;
|
||||||
|
params.sched_priority = priority;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The solaris 7 and several other man pages incorrectly state that
|
||||||
|
* this should be a pointer to policy but pthread.h is universally
|
||||||
|
* at odds with this.
|
||||||
|
*/
|
||||||
|
if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||||
|
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int policy;
|
||||||
|
struct sched_param params;
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0)
|
||||||
|
return params.sched_priority;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */
|
||||||
|
#endif /* _POSIX_PRIORITY_SCHEDULING */
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
/* exit the thread */
|
||||||
|
__gthrw_(pthread_exit) (&__objc_thread_exit_status);
|
||||||
|
|
||||||
|
/* Failed if we reached here */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return (objc_thread_t) __gthrw_(pthread_self) ();
|
||||||
|
else
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_setspecific) (_objc_thread_storage, value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_getspecific) (_objc_thread_storage);
|
||||||
|
else
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
mutex->backend = objc_malloc (sizeof (pthread_mutex_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Posix Threads specifically require that the thread be unlocked
|
||||||
|
* for __gthrw_(pthread_mutex_destroy) to work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend);
|
||||||
|
if (count < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while (count);
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (mutex->backend);
|
||||||
|
mutex->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ()
|
||||||
|
&& __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
condition->backend = objc_malloc (sizeof (pthread_cond_t));
|
||||||
|
|
||||||
|
if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL))
|
||||||
|
{
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
objc_free (condition->backend);
|
||||||
|
condition->backend = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend,
|
||||||
|
(pthread_mutex_t *) mutex->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_create (__gthread_t *__threadid, void *(*__func) (void*),
|
||||||
|
void *__args)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_create) (__threadid, NULL, __func, __args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_join (__gthread_t __threadid, void **__value_ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_join) (__threadid, __value_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_detach (__gthread_t __threadid)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_detach) (__threadid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_equal (__gthread_t __t1, __gthread_t __t2)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_equal) (__t1, __t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __gthread_t
|
||||||
|
__gthread_self (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_self) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_yield (void)
|
||||||
|
{
|
||||||
|
return __gthrw_(sched_yield) ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once, void (*__func) (void))
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_once) (__once, __func);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_create) (__key, __dtor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_key_delete (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_key_delete) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_getspecific) (__key);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key, const void *__ptr)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_setspecific) (__key, __ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_mutex_init) (__mutex, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_destroy) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_lock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_trylock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_timedlock (__gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
return __gthrw_(pthread_mutex_unlock) (__mutex);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
|
||||||
|
|| defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
{
|
||||||
|
pthread_mutexattr_t __attr;
|
||||||
|
int __r;
|
||||||
|
|
||||||
|
__r = __gthrw_(pthread_mutexattr_init) (&__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_settype) (&__attr,
|
||||||
|
PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutex_init) (__mutex, &__attr);
|
||||||
|
if (!__r)
|
||||||
|
__r = __gthrw_(pthread_mutexattr_destroy) (&__attr);
|
||||||
|
return __r;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _GTHREAD_USE_MUTEX_TIMEDLOCK
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_timedlock (__mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _GTHREAD_USE_COND_INIT_FUNC
|
||||||
|
static inline void
|
||||||
|
__gthread_cond_init_function (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
if (__gthread_active_p ())
|
||||||
|
__gthrw_(pthread_cond_init) (__cond, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_broadcast (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_broadcast) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_signal (__gthread_cond_t *__cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_signal) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_wait) (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex,
|
||||||
|
const __gthread_time_t *__abs_timeout)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_wait_recursive (__gthread_cond_t *__cond,
|
||||||
|
__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_cond_wait (__cond, __mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_cond_destroy (__gthread_cond_t* __cond)
|
||||||
|
{
|
||||||
|
return __gthrw_(pthread_cond_destroy) (__cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* Threads compatibility routines for libgcc2 and libobjc. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_SINGLE_H
|
||||||
|
|
||||||
|
/* Just provide compatibility for mutex handling. */
|
||||||
|
|
||||||
|
typedef int __gthread_key_t;
|
||||||
|
typedef int __gthread_once_t;
|
||||||
|
typedef int __gthread_mutex_t;
|
||||||
|
typedef int __gthread_recursive_mutex_t;
|
||||||
|
|
||||||
|
#define __GTHREAD_ONCE_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT 0
|
||||||
|
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
|
||||||
|
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0
|
||||||
|
|
||||||
|
#define _GLIBCXX_UNUSED __attribute__((unused))
|
||||||
|
|
||||||
|
#ifdef _LIBOBJC
|
||||||
|
|
||||||
|
/* Thread local storage for a single thread */
|
||||||
|
static void *thread_local_storage = NULL;
|
||||||
|
|
||||||
|
/* Backend initialization functions */
|
||||||
|
|
||||||
|
/* Initialize the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_init_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the threads subsystem. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_close_thread_system (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend thread functions */
|
||||||
|
|
||||||
|
/* Create a new thread of execution. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the current thread's priority. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_get_priority (void)
|
||||||
|
{
|
||||||
|
return OBJC_THREAD_INTERACTIVE_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Yield our process time to another thread. */
|
||||||
|
static inline void
|
||||||
|
__gthread_objc_thread_yield (void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the current thread. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_exit (void)
|
||||||
|
{
|
||||||
|
/* No thread support available */
|
||||||
|
/* Should we really exit the program */
|
||||||
|
/* exit (&__objc_thread_exit_status); */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns an integer value which uniquely describes a thread. */
|
||||||
|
static inline objc_thread_t
|
||||||
|
__gthread_objc_thread_id (void)
|
||||||
|
{
|
||||||
|
/* No thread support, use 1. */
|
||||||
|
return (objc_thread_t) 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets the thread's local storage pointer. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_thread_set_data (void *value)
|
||||||
|
{
|
||||||
|
thread_local_storage = value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the thread's local storage pointer. */
|
||||||
|
static inline void *
|
||||||
|
__gthread_objc_thread_get_data (void)
|
||||||
|
{
|
||||||
|
return thread_local_storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to grab a lock on a mutex. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
/* There can only be one thread, so we always get the lock */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Backend condition mutex functions */
|
||||||
|
|
||||||
|
/* Allocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deallocate a condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait on the condition */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
|
||||||
|
objc_mutex_t mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up all threads waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up one thread waiting on this condition. */
|
||||||
|
static inline int
|
||||||
|
__gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _LIBOBJC */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_active_p (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _GLIBCXX_UNUSED
|
||||||
|
__gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *
|
||||||
|
__gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_lock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_trylock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_unlock (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
|
||||||
|
{
|
||||||
|
return __gthread_mutex_destroy (__mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _LIBOBJC */
|
||||||
|
|
||||||
|
#undef _GLIBCXX_UNUSED
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
|
||||||
|
|
@ -0,0 +1,154 @@
|
||||||
|
/* Threads compatibility routines for libgcc2. */
|
||||||
|
/* Compile this one with gcc. */
|
||||||
|
/* Copyright (C) 1997-2013 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GCC.
|
||||||
|
|
||||||
|
GCC is free software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published by the Free
|
||||||
|
Software Foundation; either version 3, or (at your option) any later
|
||||||
|
version.
|
||||||
|
|
||||||
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
permissions described in the GCC Runtime Library Exception, version
|
||||||
|
3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License and
|
||||||
|
a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GCC_GTHR_H
|
||||||
|
#define _GLIBCXX_GCC_GTHR_H
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility push(default)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If this file is compiled with threads support, it must
|
||||||
|
#define __GTHREADS 1
|
||||||
|
to indicate that threads support is present. Also it has define
|
||||||
|
function
|
||||||
|
int __gthread_active_p ()
|
||||||
|
that returns 1 if thread system is active, 0 if not.
|
||||||
|
|
||||||
|
The threads interface must define the following types:
|
||||||
|
__gthread_key_t
|
||||||
|
__gthread_once_t
|
||||||
|
__gthread_mutex_t
|
||||||
|
__gthread_recursive_mutex_t
|
||||||
|
|
||||||
|
The threads interface must define the following macros:
|
||||||
|
|
||||||
|
__GTHREAD_ONCE_INIT
|
||||||
|
to initialize __gthread_once_t
|
||||||
|
__GTHREAD_MUTEX_INIT
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
__GTHREAD_MUTEX_INIT_FUNCTION
|
||||||
|
to initialize __gthread_mutex_t to get a fast
|
||||||
|
non-recursive mutex.
|
||||||
|
Define this to a function which looks like this:
|
||||||
|
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
|
||||||
|
Some systems can't initialize a mutex without a
|
||||||
|
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT
|
||||||
|
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
|
||||||
|
as above, but for a recursive mutex.
|
||||||
|
|
||||||
|
The threads interface must define the following static functions:
|
||||||
|
|
||||||
|
int __gthread_once (__gthread_once_t *once, void (*func) ())
|
||||||
|
|
||||||
|
int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
|
||||||
|
int __gthread_key_delete (__gthread_key_t key)
|
||||||
|
|
||||||
|
void *__gthread_getspecific (__gthread_key_t key)
|
||||||
|
int __gthread_setspecific (__gthread_key_t key, const void *ptr)
|
||||||
|
|
||||||
|
int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_mutex_lock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
|
||||||
|
int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
|
||||||
|
|
||||||
|
int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
The following are supported in POSIX threads only. They are required to
|
||||||
|
fix a deadlock in static initialization inside libsupc++. The header file
|
||||||
|
gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra
|
||||||
|
features are supported.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_cond_t
|
||||||
|
|
||||||
|
Macros:
|
||||||
|
__GTHREAD_COND_INIT
|
||||||
|
__GTHREAD_COND_INIT_FUNCTION
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_cond_broadcast (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex);
|
||||||
|
int __gthread_cond_wait_recursive (__gthread_cond_t *cond,
|
||||||
|
__gthread_recursive_mutex_t *mutex);
|
||||||
|
|
||||||
|
All functions returning int should return zero on success or the error
|
||||||
|
number. If the operation is not supported, -1 is returned.
|
||||||
|
|
||||||
|
If the following are also defined, you should
|
||||||
|
#define __GTHREADS_CXX0X 1
|
||||||
|
to enable the c++0x thread library.
|
||||||
|
|
||||||
|
Types:
|
||||||
|
__gthread_t
|
||||||
|
__gthread_time_t
|
||||||
|
|
||||||
|
Interface:
|
||||||
|
int __gthread_create (__gthread_t *thread, void *(*func) (void*),
|
||||||
|
void *args);
|
||||||
|
int __gthread_join (__gthread_t thread, void **value_ptr);
|
||||||
|
int __gthread_detach (__gthread_t thread);
|
||||||
|
int __gthread_equal (__gthread_t t1, __gthread_t t2);
|
||||||
|
__gthread_t __gthread_self (void);
|
||||||
|
int __gthread_yield (void);
|
||||||
|
|
||||||
|
int __gthread_mutex_timedlock (__gthread_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m,
|
||||||
|
const __gthread_time_t *abs_time);
|
||||||
|
|
||||||
|
int __gthread_cond_signal (__gthread_cond_t *cond);
|
||||||
|
int __gthread_cond_timedwait (__gthread_cond_t *cond,
|
||||||
|
__gthread_mutex_t *mutex,
|
||||||
|
const __gthread_time_t *abs_timeout);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __GXX_WEAK__
|
||||||
|
/* The pe-coff weak support isn't fully compatible to ELF's weak.
|
||||||
|
For static libraries it might would work, but as we need to deal
|
||||||
|
with shared versions too, we disable it for mingw-targets. */
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#undef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_GTHREAD_USE_WEAK
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#include <bits/gthr-default.h>
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_HIDE_EXPORTS
|
||||||
|
#pragma GCC visibility pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* ! _GLIBCXX_GCC_GTHR_H */
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::messages implementation details, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/messages_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Non-virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::messages(__c_locale, const char*, size_t __refs)
|
||||||
|
: facet(__refs)
|
||||||
|
{ _M_c_locale_messages = _S_get_c_locale(); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
|
||||||
|
const char*) const
|
||||||
|
{ return this->do_open(__s, __loc); }
|
||||||
|
|
||||||
|
// Virtual member functions.
|
||||||
|
template<typename _CharT>
|
||||||
|
messages<_CharT>::~messages()
|
||||||
|
{ _S_destroy_c_locale(_M_c_locale_messages); }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::catalog
|
||||||
|
messages<_CharT>::do_open(const basic_string<char>&, const locale&) const
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
typename messages<_CharT>::string_type
|
||||||
|
messages<_CharT>::do_get(catalog, int, int,
|
||||||
|
const string_type& __dfault) const
|
||||||
|
{ return __dfault; }
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
void
|
||||||
|
messages<_CharT>::do_close(catalog) const
|
||||||
|
{ }
|
||||||
|
|
||||||
|
// messages_byname
|
||||||
|
template<typename _CharT>
|
||||||
|
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
|
||||||
|
: messages<_CharT>(__refs)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, "C") != 0
|
||||||
|
&& __builtin_strcmp(__s, "POSIX") != 0)
|
||||||
|
{
|
||||||
|
this->_S_destroy_c_locale(this->_M_c_locale_messages);
|
||||||
|
this->_S_create_c_locale(this->_M_c_locale_messages, __s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number handling, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _BITS_OPT_RANDOM_H
|
||||||
|
#define _BITS_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _BITS_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Specific definitions for newlib -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/os_defines.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{iosfwd}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_OS_DEFINES
|
||||||
|
#define _GLIBCXX_OS_DEFINES 1
|
||||||
|
|
||||||
|
// System-specific #define, typedefs, corrections, etc, go here. This
|
||||||
|
// file will come before all others.
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
#define _GLIBCXX_GTHREAD_USE_WEAK 0
|
||||||
|
|
||||||
|
#if defined (_GLIBCXX_DLL)
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default __attribute__ ((__dllimport__))
|
||||||
|
#else
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_default
|
||||||
|
#endif
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY_hidden
|
||||||
|
|
||||||
|
#define _GLIBCXX_PSEUDO_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY_ ## V
|
||||||
|
|
||||||
|
// See libstdc++/20806.
|
||||||
|
#define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
// C++ includes used for precompiling -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdc++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 17.4.1.2 Headers
|
||||||
|
|
||||||
|
// C
|
||||||
|
#ifndef _GLIBCXX_NO_ASSERT
|
||||||
|
#include <cassert>
|
||||||
|
#endif
|
||||||
|
#include <cctype>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <ciso646>
|
||||||
|
#include <climits>
|
||||||
|
#include <clocale>
|
||||||
|
#include <cmath>
|
||||||
|
#include <csetjmp>
|
||||||
|
#include <csignal>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <ccomplex>
|
||||||
|
#include <cfenv>
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <cstdalign>
|
||||||
|
#include <cstdbool>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <ctgmath>
|
||||||
|
#include <cwchar>
|
||||||
|
#include <cwctype>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// C++
|
||||||
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <complex>
|
||||||
|
#include <deque>
|
||||||
|
#include <exception>
|
||||||
|
#include <fstream>
|
||||||
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <istream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <limits>
|
||||||
|
#include <list>
|
||||||
|
#include <locale>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <new>
|
||||||
|
#include <numeric>
|
||||||
|
#include <ostream>
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stack>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <typeinfo>
|
||||||
|
#include <utility>
|
||||||
|
#include <valarray>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
#include <array>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <forward_list>
|
||||||
|
#include <future>
|
||||||
|
#include <initializer_list>
|
||||||
|
#include <mutex>
|
||||||
|
#include <random>
|
||||||
|
#include <ratio>
|
||||||
|
#include <regex>
|
||||||
|
#include <scoped_allocator>
|
||||||
|
#include <system_error>
|
||||||
|
#include <thread>
|
||||||
|
#include <tuple>
|
||||||
|
#include <typeindex>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
// C++ includes used for precompiling TR1 -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2006-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file stdtr1c++.h
|
||||||
|
* This is an implementation file for a precompiled header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
#include <tr1/array>
|
||||||
|
#include <tr1/cctype>
|
||||||
|
#include <tr1/cfenv>
|
||||||
|
#include <tr1/cfloat>
|
||||||
|
#include <tr1/cinttypes>
|
||||||
|
#include <tr1/climits>
|
||||||
|
#include <tr1/cmath>
|
||||||
|
#include <tr1/complex>
|
||||||
|
#include <tr1/cstdarg>
|
||||||
|
#include <tr1/cstdbool>
|
||||||
|
#include <tr1/cstdint>
|
||||||
|
#include <tr1/cstdio>
|
||||||
|
#include <tr1/cstdlib>
|
||||||
|
#include <tr1/ctgmath>
|
||||||
|
#include <tr1/ctime>
|
||||||
|
#include <tr1/cwchar>
|
||||||
|
#include <tr1/cwctype>
|
||||||
|
#include <tr1/functional>
|
||||||
|
#include <tr1/random>
|
||||||
|
#include <tr1/tuple>
|
||||||
|
#include <tr1/unordered_map>
|
||||||
|
#include <tr1/unordered_set>
|
||||||
|
#include <tr1/utility>
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/time_members.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{locale}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 22.2.5.1.2 - time_get functions
|
||||||
|
// ISO C++ 14882: 22.2.5.3.2 - time_put functions
|
||||||
|
//
|
||||||
|
|
||||||
|
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
|
||||||
|
: facet(__refs), _M_data(__cache)
|
||||||
|
{
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
_M_initialize_timepunct();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
|
||||||
|
size_t __refs)
|
||||||
|
: facet(__refs), _M_data(0)
|
||||||
|
{
|
||||||
|
if (__builtin_strcmp(__s, _S_get_c_name()) != 0)
|
||||||
|
{
|
||||||
|
const size_t __len = __builtin_strlen(__s) + 1;
|
||||||
|
char* __tmp = new char[__len];
|
||||||
|
__builtin_memcpy(__tmp, __s, __len);
|
||||||
|
_M_name_timepunct = __tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_M_name_timepunct = _S_get_c_name();
|
||||||
|
|
||||||
|
__try
|
||||||
|
{ _M_initialize_timepunct(__cloc); }
|
||||||
|
__catch(...)
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
__throw_exception_again;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename _CharT>
|
||||||
|
__timepunct<_CharT>::~__timepunct()
|
||||||
|
{
|
||||||
|
if (_M_name_timepunct != _S_get_c_name())
|
||||||
|
delete [] _M_name_timepunct;
|
||||||
|
delete _M_data;
|
||||||
|
_S_destroy_c_locale(_M_c_locale_timepunct);
|
||||||
|
}
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Optimizations for random number extensions, generic version -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2012-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file ext/opt_random.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ext/random}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EXT_OPT_RANDOM_H
|
||||||
|
#define _EXT_OPT_RANDOM_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _EXT_OPT_RANDOM_H
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Low-level type for atomic operations -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file atomic_word.h
|
||||||
|
* This file is a GNU extension to the Standard C++ Library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_ATOMIC_WORD_H
|
||||||
|
#define _GLIBCXX_ATOMIC_WORD_H 1
|
||||||
|
|
||||||
|
typedef int _Atomic_word;
|
||||||
|
|
||||||
|
// Define these two macros using the appropriate memory barrier for the target.
|
||||||
|
// The commented out versions below are the defaults.
|
||||||
|
// See ia64/atomic_word.h for an alternative approach.
|
||||||
|
|
||||||
|
// This one prevents loads from being hoisted across the barrier;
|
||||||
|
// in other words, this is a Load-Load acquire barrier.
|
||||||
|
// This is necessary iff TARGET_RELAXED_ORDERING is defined in tm.h.
|
||||||
|
// #define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
// This one prevents stores from being sunk across the barrier; in other
|
||||||
|
// words, a Store-Store release barrier.
|
||||||
|
// #define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
// Wrapper of C-language FILE struct -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISO C++ 14882: 27.8 File-based streams
|
||||||
|
//
|
||||||
|
|
||||||
|
/** @file bits/basic_file.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_BASIC_FILE_STDIO_H
|
||||||
|
#define _GLIBCXX_BASIC_FILE_STDIO_H 1
|
||||||
|
|
||||||
|
#pragma GCC system_header
|
||||||
|
|
||||||
|
#include <bits/c++config.h>
|
||||||
|
#include <bits/c++io.h> // for __c_lock and __c_file
|
||||||
|
#include <ios>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
// Generic declaration.
|
||||||
|
template<typename _CharT>
|
||||||
|
class __basic_file;
|
||||||
|
|
||||||
|
// Specialization.
|
||||||
|
template<>
|
||||||
|
class __basic_file<char>
|
||||||
|
{
|
||||||
|
// Underlying data source/sink.
|
||||||
|
__c_file* _M_cfile;
|
||||||
|
|
||||||
|
// True iff we opened _M_cfile, and thus must close it ourselves.
|
||||||
|
bool _M_cfile_created;
|
||||||
|
|
||||||
|
public:
|
||||||
|
__basic_file(__c_lock* __lock = 0) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(__c_file* __file, ios_base::openmode);
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
sys_open(int __fd, ios_base::openmode __mode) throw ();
|
||||||
|
|
||||||
|
__basic_file*
|
||||||
|
close();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE bool
|
||||||
|
is_open() const throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE int
|
||||||
|
fd() throw ();
|
||||||
|
|
||||||
|
_GLIBCXX_PURE __c_file*
|
||||||
|
file() throw ();
|
||||||
|
|
||||||
|
~__basic_file();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn(const char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsputn_2(const char* __s1, streamsize __n1,
|
||||||
|
const char* __s2, streamsize __n2);
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
xsgetn(char* __s, streamsize __n);
|
||||||
|
|
||||||
|
streamoff
|
||||||
|
seekoff(streamoff __off, ios_base::seekdir __way) throw ();
|
||||||
|
|
||||||
|
int
|
||||||
|
sync();
|
||||||
|
|
||||||
|
streamsize
|
||||||
|
showmanyc();
|
||||||
|
};
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
// Base to std::allocator -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2004-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++allocator.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{memory}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_ALLOCATOR_H
|
||||||
|
#define _GLIBCXX_CXX_ALLOCATOR_H 1
|
||||||
|
|
||||||
|
#include <ext/new_allocator.h>
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief An alias to the base class for std::allocator.
|
||||||
|
* @ingroup allocators
|
||||||
|
*
|
||||||
|
* Used to set the std::allocator base class to
|
||||||
|
* __gnu_cxx::new_allocator.
|
||||||
|
*
|
||||||
|
* @tparam _Tp Type of allocated object.
|
||||||
|
*/
|
||||||
|
template<typename _Tp>
|
||||||
|
using __allocator_base = __gnu_cxx::new_allocator<_Tp>;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Define new_allocator as the base class to std::allocator.
|
||||||
|
# define __allocator_base __gnu_cxx::new_allocator
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Underlying io library details -*- C++ -*-
|
||||||
|
|
||||||
|
// Copyright (C) 2000-2013 Free Software Foundation, Inc.
|
||||||
|
//
|
||||||
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
|
// software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the
|
||||||
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
|
// any later version.
|
||||||
|
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License and
|
||||||
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/** @file bits/c++io.h
|
||||||
|
* This is an internal header file, included by other library headers.
|
||||||
|
* Do not attempt to use it directly. @headername{ios}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// c_io_stdio.h - Defines for using "C" stdio.h
|
||||||
|
|
||||||
|
#ifndef _GLIBCXX_CXX_IO_H
|
||||||
|
#define _GLIBCXX_CXX_IO_H 1
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <bits/gthr.h>
|
||||||
|
|
||||||
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
|
{
|
||||||
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
|
typedef __gthread_mutex_t __c_lock;
|
||||||
|
|
||||||
|
// for basic_file.h
|
||||||
|
typedef FILE __c_file;
|
||||||
|
|
||||||
|
_GLIBCXX_END_NAMESPACE_VERSION
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue