summaryrefslogtreecommitdiff
path: root/tests/nbody-java/xmlvm-hy.h
blob: 843a2753b2c7b9164d6f7880885f98d6d778ee82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Copyright (c) 2002-2011 by XMLVM.org
 *
 * Project Info:  http://www.xmlvm.org
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, 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 Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 */

#ifndef __XMLVM_HY_H__

#define __XMLVM_HY_H__

#ifdef __APPLE__
#define MACOSX
#endif

#include "xmlvm.h"
#include "hycomp.h"
#include "hysock.h"
#include "hysocket.h"


#define HYERROR_DEFAULT_BUFFER_SIZE 256 /**< default customized error message size if we need to create one */

#if defined(__linux__)
#define DIR_SEPARATOR '/'
#endif


typedef struct PortlibPTBuffers_struct
{
    I_32 platformErrorCode;         /**< error code as reported by the OS */
    I_32 portableErrorCode;         /**< error code translated to portable format by application */
    char *errorMessageBuffer;       /**< last saved error message, either customized or from OS */
    U_32 errorMessageBufferSize;    /**< error message buffer size */
    I_32 reportedErrorCode;         /**< last reported error code */
    char *reportedMessageBuffer;    /**< last reported error message, either customized or from OS */
    U_32 reportedMessageBufferSize; /**< reported message buffer size */   
    hyfdset_t fdset;                                  
                                   
#if HOSTENT_DATA_R||GLIBC_R||OTHER_R||NO_R
    OSHOSTENT hostent;
#endif
    
#if HOSTENT_DATA_R
    OSHOSTENT_DATA *hostent_data;
#elif GLIBC_R || OTHER_R || NO_R
    int gethostBufferSize;
    char *gethostBuffer;
#endif                          /* HOSTENT_DATA_R */
    
} PortlibPTBuffers_struct;

typedef struct PortlibPTBuffers_struct *PortlibPTBuffers_t;

 
typedef pthread_mutex_t MUTEX;

/* MUTEX_INIT */
#define MUTEX_INIT(mutex) (pthread_mutex_init(&(mutex), NULL) == 0)

/* MUTEX_DESTROY */
#define MUTEX_DESTROY(mutex) pthread_mutex_destroy(&(mutex))

/* MUTEX_ENTER */
#define MUTEX_ENTER(mutex) pthread_mutex_lock(&(mutex))

/*
 *  MUTEX_TRY_ENTER 
 *  returns 0 on success
 */
#define MUTEX_TRY_ENTER(mutex) pthread_mutex_trylock(&(mutex))

/* MUTEX_EXIT */
#define MUTEX_EXIT(mutex) pthread_mutex_unlock(&(mutex))


#if defined(SEEK_SET)
#define HySeekSet SEEK_SET        /* Values for HyFileSeek */
#else
#define HySeekSet 0
#endif

#if defined(SEEK_CUR)
#define HySeekCur SEEK_CUR
#else
#define HySeekCur 1
#endif

#if defined(SEEK_END)
#define HySeekEnd SEEK_END
#else
#define HySeekEnd 2
#endif


typedef JAVA_INT jsize;


void* hyport_tls_get ();
void* hyport_tls_peek ();
const char* hyerror_last_error_message ();
I_32 hyerror_last_error_number ();
I_32 hyerror_set_last_error (I_32 platformCode, I_32 portableCode);
I_32 hyerror_set_last_error_with_message (I_32 portableCode, const char *errorMessage);


#endif