1 /* 2 * Copyright (c) 2001, 2002, 2004 X-Way Rights BV 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 */ 19 20 /*!\file api.h 21 * \brief BeeCrypt API, portability headers. 22 * \author Bob Deblier <bob.deblier@telenet.be> 23 */ 24 25 #ifndef _BEECRYPT_API_H 26 #define _BEECRYPT_API_H 27 28 #if defined(_WIN32) && !defined(WIN32) 29 # define WIN32 1 30 #endif 31 32 #if WIN32 33 # if !__CYGWIN32__ && !__MINGW32__ 34 # include "beecrypt/win.h" 35 # else 36 # include "beecrypt/gnu.h" 37 # endif 38 # ifdef BEECRYPT_DLL_EXPORT 39 # define BEECRYPTAPI __declspec(dllexport) 40 # else 41 # define BEECRYPTAPI __declspec(dllimport) 42 # endif 43 # ifdef BEECRYPT_CXX_DLL_EXPORT 44 # define BEECRYPTCXXAPI __declspec(dllexport) 45 # define BEECRYPTCXXTEMPLATE 46 # else 47 # define BEECRYPTCXXAPI __declspec(dllimport) 48 # define BEECRYPTCXXTEMPLATE extern 49 # endif 50 #else 51 # include "beecrypt/gnu.h" 52 # define BEECRYPTAPI 53 # define BEECRYPTCXXAPI 54 #endif 55 56 #if HAVE_ASSERT_H 57 # include <assert.h> 58 #else 59 # define assert(x) 60 #endif 61 62 #ifndef ROTL32 63 # define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s)))) 64 #endif 65 #ifndef ROTR32 66 # define ROTR32(x, s) (((x) >> (s)) | ((x) << (32 - (s)))) 67 #endif 68 #ifndef ROTR64 69 # define ROTR64(x, s) (((x) >> (s)) | ((x) << (64 - (s)))) 70 #endif 71 72 typedef uint8_t byte; 73 74 #if JAVAGLUE 75 # include <jni.h> 76 #else 77 typedef int8_t jbyte; 78 typedef int16_t jshort; 79 typedef int32_t jint; 80 typedef int64_t jlong; 81 typedef uint16_t jchar; 82 typedef float jfloat; 83 typedef double jdouble; 84 #endif 85 86 #if (MP_WBITS == 64) 87 typedef uint64_t mpw; 88 typedef uint32_t mphw; 89 #elif (MP_WBITS == 32) 90 # if HAVE_UINT64_T 91 # define HAVE_MPDW 1 92 typedef uint64_t mpdw; 93 # endif 94 typedef uint32_t mpw; 95 typedef uint16_t mphw; 96 #else 97 # error 98 #endif 99 100 #endif 101