Compare commits
No commits in common. "2248f9e3aae1665e8d18004a09d41f12c00ea225" and "7c0333124be43207b5ac65f5c97369aad255054f" have entirely different histories.
2248f9e3aa
...
7c0333124b
6 changed files with 9 additions and 158 deletions
|
|
@ -1,45 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
project(sj3 VERSION 2.0.99 LANGUAGES C)
|
|
||||||
|
|
||||||
include(CheckCSourceCompiles)
|
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_C_STANDARD)
|
|
||||||
set(CMAKE_C_STANDARD 90)
|
|
||||||
endif()
|
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
|
||||||
|
|
||||||
set(SJ3CONFDIR "/etc/sj3" CACHE PATH "SJ3 configuration directory")
|
|
||||||
set(SJ3DICTDIR "${CMAKE_INSTALL_PREFIX}/share/sj3/dict" CACHE PATH
|
|
||||||
"SJ3 dictionary directory")
|
|
||||||
|
|
||||||
check_c_source_compiles("
|
|
||||||
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
|
|
||||||
# error C99 required
|
|
||||||
#endif
|
|
||||||
#include <stdint.h>
|
|
||||||
int main(void) {
|
|
||||||
uint8_t u8 = 0;
|
|
||||||
uint16_t u16 = 0;
|
|
||||||
uint32_t u32 = 0;
|
|
||||||
uint64_t u64 = 0;
|
|
||||||
return (int)(u8 + u16 + u32 + u64);
|
|
||||||
}
|
|
||||||
" HAVE_C99_STDINT)
|
|
||||||
|
|
||||||
configure_file(config.h.cmake config.h @ONLY)
|
|
||||||
configure_file(Paths.h.in Paths.h @ONLY)
|
|
||||||
|
|
||||||
add_library(sj3types INTERFACE)
|
|
||||||
target_include_directories(sj3types INTERFACE
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(sj3_core_types OBJECT
|
|
||||||
wc16_str.c
|
|
||||||
string.c
|
|
||||||
string2.c
|
|
||||||
)
|
|
||||||
target_link_libraries(sj3_core_types PRIVATE sj3types)
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#ifndef OCONFIGURE_CONFIG_H
|
|
||||||
#define OCONFIGURE_CONFIG_H
|
|
||||||
|
|
||||||
#cmakedefine01 HAVE_C99_STDINT
|
|
||||||
|
|
||||||
#ifndef HAVE_MD5
|
|
||||||
# define HAVE_MD5 1
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_SHA2
|
|
||||||
# define HAVE_SHA2 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* OCONFIGURE_CONFIG_H */
|
|
||||||
5
configure
vendored
5
configure
vendored
|
|
@ -221,7 +221,6 @@ HAVE_B64_NTOP=
|
||||||
HAVE_CAPSICUM=
|
HAVE_CAPSICUM=
|
||||||
HAVE_CRYPT=
|
HAVE_CRYPT=
|
||||||
HAVE_CRYPT_NEWHASH=
|
HAVE_CRYPT_NEWHASH=
|
||||||
HAVE_C99_STDINT=
|
|
||||||
HAVE_ENDIAN_H=
|
HAVE_ENDIAN_H=
|
||||||
HAVE_ERR=
|
HAVE_ERR=
|
||||||
HAVE_EXPLICIT_BZERO=
|
HAVE_EXPLICIT_BZERO=
|
||||||
|
|
@ -392,7 +391,6 @@ runtest b64_ntop B64_NTOP "" "" "-lresolv" || true
|
||||||
runtest capsicum CAPSICUM || true
|
runtest capsicum CAPSICUM || true
|
||||||
runtest crypt CRYPT "" "" "-lcrypt" || true
|
runtest crypt CRYPT "" "" "-lcrypt" || true
|
||||||
runtest crypt_newhash CRYPT_NEWHASH || true
|
runtest crypt_newhash CRYPT_NEWHASH || true
|
||||||
runtest c99_stdint C99_STDINT || true
|
|
||||||
runtest endian_h ENDIAN_H || true
|
runtest endian_h ENDIAN_H || true
|
||||||
runtest err ERR || true
|
runtest err ERR || true
|
||||||
runtest explicit_bzero EXPLICIT_BZERO || true
|
runtest explicit_bzero EXPLICIT_BZERO || true
|
||||||
|
|
@ -515,7 +513,7 @@ fi
|
||||||
if [ ${HAVE_MD5} -eq 0 -o \
|
if [ ${HAVE_MD5} -eq 0 -o \
|
||||||
${HAVE_SHA2} -eq 0 ]
|
${HAVE_SHA2} -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "#include \"sj_stdint.h\" /* C99 stdint.h or C89 fallback types */"
|
echo "#include <stdint.h> /* C99 [u]int[nn]_t types */"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -557,7 +555,6 @@ cat << __HEREDOC__
|
||||||
#define HAVE_CAPSICUM ${HAVE_CAPSICUM}
|
#define HAVE_CAPSICUM ${HAVE_CAPSICUM}
|
||||||
#define HAVE_CRYPT ${HAVE_CRYPT}
|
#define HAVE_CRYPT ${HAVE_CRYPT}
|
||||||
#define HAVE_CRYPT_NEWHASH ${HAVE_CRYPT_NEWHASH}
|
#define HAVE_CRYPT_NEWHASH ${HAVE_CRYPT_NEWHASH}
|
||||||
#define HAVE_C99_STDINT ${HAVE_C99_STDINT}
|
|
||||||
#define HAVE_ENDIAN_H ${HAVE_ENDIAN_H}
|
#define HAVE_ENDIAN_H ${HAVE_ENDIAN_H}
|
||||||
#define HAVE_ERR ${HAVE_ERR}
|
#define HAVE_ERR ${HAVE_ERR}
|
||||||
#define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
|
#define HAVE_EXPLICIT_BZERO ${HAVE_EXPLICIT_BZERO}
|
||||||
|
|
|
||||||
66
sj_stdint.h
66
sj_stdint.h
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: MIT
|
|
||||||
*
|
|
||||||
* Small fixed-width integer compatibility layer for SJ3.
|
|
||||||
*
|
|
||||||
* In C99 or newer translation units, use <stdint.h>. In C89 translation
|
|
||||||
* units, provide the fixed-width names that SJ3 needs when the host integer
|
|
||||||
* model has matching types.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SJ_STDINT_H_
|
|
||||||
#define SJ_STDINT_H_
|
|
||||||
|
|
||||||
#if defined(HAVE_C99_STDINT) && HAVE_C99_STDINT && \
|
|
||||||
defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#if !defined(UINT8_MAX)
|
|
||||||
# if UCHAR_MAX == 255
|
|
||||||
typedef signed char int8_t;
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
# define UINT8_MAX UCHAR_MAX
|
|
||||||
# else
|
|
||||||
# error "SJ3 requires an 8-bit unsigned char"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(UINT16_MAX)
|
|
||||||
# if USHRT_MAX == 65535
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
# define UINT16_MAX USHRT_MAX
|
|
||||||
# else
|
|
||||||
# error "SJ3 requires a 16-bit unsigned short"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(UINT32_MAX)
|
|
||||||
# if UINT_MAX == 4294967295U
|
|
||||||
typedef int int32_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
# define UINT32_MAX UINT_MAX
|
|
||||||
# elif ULONG_MAX == 4294967295UL
|
|
||||||
typedef long int32_t;
|
|
||||||
typedef unsigned long uint32_t;
|
|
||||||
# define UINT32_MAX ULONG_MAX
|
|
||||||
# else
|
|
||||||
# error "SJ3 requires a 32-bit integer type"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(UINT64_MAX) && (ULONG_MAX > 4294967295UL)
|
|
||||||
typedef long int64_t;
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
# define UINT64_MAX ULONG_MAX
|
|
||||||
#elif !defined(UINT64_MAX) && (defined(_MSC_VER) || defined(_WIN32))
|
|
||||||
typedef __int64 int64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* SJ_STDINT_H_ */
|
|
||||||
17
sj_typedef.h
17
sj_typedef.h
|
|
@ -40,18 +40,17 @@
|
||||||
#define _SJ_TYPEDEF 1
|
#define _SJ_TYPEDEF 1
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "sj_stdint.h"
|
|
||||||
|
|
||||||
typedef uint8_t TypeGroup;
|
typedef unsigned char TypeGroup;
|
||||||
typedef uint8_t TypeGram;
|
typedef unsigned char TypeGram;
|
||||||
typedef uint16_t TypeIdxOfs;
|
typedef unsigned short TypeIdxOfs;
|
||||||
typedef short TypeDicSeg;
|
typedef short TypeDicSeg;
|
||||||
typedef uint16_t TypeDicOfs;
|
typedef unsigned short TypeDicOfs;
|
||||||
typedef ino_t TypeDicID;
|
typedef ino_t TypeDicID;
|
||||||
typedef uint8_t TypeCnct;
|
typedef unsigned char TypeCnct;
|
||||||
typedef uint16_t TypeStyNum;
|
typedef unsigned short TypeStyNum;
|
||||||
typedef uint8_t TypeClass;
|
typedef unsigned char TypeClass;
|
||||||
typedef uint8_t TypeBunNum;
|
typedef unsigned char TypeBunNum;
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
# define NULL 0
|
# define NULL 0
|
||||||
|
|
|
||||||
21
tests.c
21
tests.c
|
|
@ -81,27 +81,6 @@ main(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* TEST_CRYPT_NEWHASH */
|
#endif /* TEST_CRYPT_NEWHASH */
|
||||||
#if TEST_C99_STDINT
|
|
||||||
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
|
|
||||||
# error "C99 is required for stdint.h"
|
|
||||||
#endif
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
|
||||||
uint8_t u8;
|
|
||||||
uint16_t u16;
|
|
||||||
uint32_t u32;
|
|
||||||
uint64_t u64;
|
|
||||||
|
|
||||||
u8 = 0;
|
|
||||||
u16 = 0;
|
|
||||||
u32 = 0;
|
|
||||||
u64 = 0;
|
|
||||||
return (int)(u8 + u16 + u32 + u64);
|
|
||||||
}
|
|
||||||
#endif /* TEST_C99_STDINT */
|
|
||||||
#if TEST_ENDIAN_H
|
#if TEST_ENDIAN_H
|
||||||
#if defined(__linux__) || defined(__wasi__)
|
#if defined(__linux__) || defined(__wasi__)
|
||||||
# define _DEFAULT_SOURCE
|
# define _DEFAULT_SOURCE
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue