intégration des logiciels tier comme NanoMQ ainsi que les fichiers json de score

This commit is contained in:
2024-11-18 22:44:28 +01:00
parent 8f2ed89e05
commit a04c4c1f59
138 changed files with 27816 additions and 0 deletions

View File

@ -0,0 +1,42 @@
//
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#ifndef NNG_SUPPLEMENTAL_UTIL_IDHASH_H
#define NNG_SUPPLEMENTAL_UTIL_IDHASH_H
#ifdef __cplusplus
extern "C" {
#endif
#include <nng/nng.h>
typedef struct nng_id_map_s nng_id_map;
#define NNG_MAP_RANDOM 1
// For NanoNNG
NNG_DECL void nng_id_map_foreach(
nng_id_map *map, void (*)(void *, void *));
NNG_DECL void nng_id_map_foreach2(nng_id_map *map,
void (*)(void *, void *, void *), void *);
NNG_DECL int nng_id_map_alloc(
nng_id_map **map, uint64_t lo, uint64_t hi, int flags);
NNG_DECL void nng_id_map_free(nng_id_map *map);
NNG_DECL void *nng_id_get(nng_id_map *, uint64_t);
NNG_DECL int nng_id_set(nng_id_map *, uint64_t, void *);
NNG_DECL int nng_id_alloc(nng_id_map *, uint64_t *, void *);
NNG_DECL int nng_id_remove(nng_id_map *, uint64_t);
NNG_DECL bool nng_id_visit(nng_id_map *, uint64_t *, void **, uint32_t *);
#ifdef __cplusplus
}
#endif
#endif // NNG_SUPPLEMENTAL_IDHASH_IDHASH_H

View File

@ -0,0 +1,50 @@
//
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#ifndef NNG_SUPPLEMENTAL_UTIL_OPTIONS_H
#define NNG_SUPPLEMENTAL_UTIL_OPTIONS_H
#include <stdbool.h>
#include <nng/nng.h>
#ifdef __cplusplus
extern "C" {
#endif
// This is a relatively simple "options parsing" library, used to
// parse command line options. We would use getopt(3), but there are
// two problems with getopt(3). First, it isn't available on all
// platforms (especially Win32), and second, it doesn't support long
// options. We *exclusively* support long options. POSIX style
// short option clustering is *NOT* supported.
struct nng_optspec {
const char *o_name; // Long style name (may be NULL for short only)
int o_short; // Short option (no clustering!)
int o_val; // Value stored on a good parse (>0)
bool o_arg; // Option takes an argument if true
};
typedef struct nng_optspec nng_optspec;
// Call with *optidx set to 1 to start parsing for a standard program.
// The val will store the value of the matched "o_val", optarg will be
// set to match the option string, and optidx will be increment appropriately.
// Returns -1 when the end of options is reached, 0 on success, or
// NNG_EINVAL if the option parse is invalid for any reason.
NNG_DECL int nng_opts_parse(int argc, char *const *argv,
const nng_optspec *opts, int *val, char **optarg, int *optidx);
#ifdef __cplusplus
}
#endif
#endif // NNG_SUPPLEMENTAL_UTIL_OPTIONS_H

View File

@ -0,0 +1,119 @@
//
// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
#ifndef NNG_SUPPLEMENTAL_UTIL_PLATFORM_H
#define NNG_SUPPLEMENTAL_UTIL_PLATFORM_H
// The declarations in this file are provided to assist with application
// portability. Conceptually these APIs are based on work we have already
// done for NNG internals, and we find that they are useful in building
// portable applications.
// If it is more natural to use native system APIs like pthreads or C11
// APIs or Windows APIs, then by all means please feel free to simply
// ignore this.
#include <stddef.h>
#include <stdint.h>
#include <nng/nng.h>
#ifdef __cplusplus
extern "C" {
#endif
// Return unix timestamp (milliseconds) .
NNG_DECL nng_time nng_timestamp(void);
// Get current process Id.
NNG_DECL int nng_getpid();
// nng_rwlock is a rwlock. TODO more comments
typedef struct nng_rwlock nng_rwlock;
NNG_DECL int nng_rwlock_alloc(nng_rwlock **);
NNG_DECL void nng_rwlock_free(nng_rwlock *);
NNG_DECL void nng_rwlock_rdlock(nng_rwlock *);
NNG_DECL void nng_rwlock_rwlock(nng_rwlock *);
NNG_DECL void nng_rwlock_unlock(nng_rwlock *);
//
// Atomics support. This will evolve over time.
//
// nng_atomic_flag supports only test-and-set and reset operations.
// This can be implemented without locks on any reasonable system, and
// it corresponds to C11 atomic flag.
typedef struct nni_atomic_flag nng_atomic_flag;
NNG_DECL bool nng_atomic_flag_test_and_set(nng_atomic_flag *);
NNG_DECL void nng_atomic_flag_reset(nng_atomic_flag *);
// nng_atomic_bool is for boolean flags that need to be checked without
// changing their value. This might require a lock on some systems.
typedef struct nni_atomic_bool nng_atomic_bool;
NNG_DECL int nng_atomic_alloc_bool(nng_atomic_bool **v);
NNG_DECL void nng_atomic_free_bool(nng_atomic_bool *v);
NNG_DECL void nng_atomic_set_bool(nng_atomic_bool *, bool);
NNG_DECL bool nng_atomic_get_bool(nng_atomic_bool *);
NNG_DECL bool nng_atomic_swap_bool(nng_atomic_bool *, bool);
typedef struct nni_atomic_u64 nng_atomic_u64;
NNG_DECL int nng_atomic_alloc64(nng_atomic_u64 **v);
NNG_DECL void nng_atomic_free64(nng_atomic_u64 *v);
NNG_DECL void nng_atomic_add64(nng_atomic_u64 *, uint64_t);
NNG_DECL void nng_atomic_sub64(nng_atomic_u64 *, uint64_t);
NNG_DECL uint64_t nng_atomic_get64(nng_atomic_u64 *);
NNG_DECL void nng_atomic_set64(nng_atomic_u64 *, uint64_t);
NNG_DECL uint64_t nng_atomic_swap64(nng_atomic_u64 *, uint64_t);
NNG_DECL uint64_t nng_atomic_dec64_nv(nng_atomic_u64 *);
NNG_DECL void nng_atomic_inc64(nng_atomic_u64 *);
// nng_atomic_cas64 is a compare and swap. The second argument is the
// value to compare against, and the third is the new value. Returns
// true if the value was set.
NNG_DECL bool nng_atomic_cas64(nng_atomic_u64 *, uint64_t, uint64_t);
// In a lot of circumstances, we want a simple atomic reference count,
// or atomic tunable values for integers like queue lengths or TTLs.
// These native integer forms should be preferred over the 64 bit versions
// unless larger bit sizes are truly needed. They will be more efficient
// on many platforms.
typedef struct nni_atomic_int nng_atomic_int;
NNG_DECL int nng_atomic_alloc(nng_atomic_int **v);
NNG_DECL void nng_atomic_free(nng_atomic_int *v);
NNG_DECL void nng_atomic_add(nng_atomic_int *, int);
NNG_DECL void nng_atomic_sub(nng_atomic_int *, int);
NNG_DECL int nng_atomic_get(nng_atomic_int *);
NNG_DECL void nng_atomic_set(nng_atomic_int *, int);
NNG_DECL int nng_atomic_swap(nng_atomic_int *, int);
NNG_DECL int nng_atomic_dec_nv(nng_atomic_int *);
NNG_DECL void nng_atomic_dec(nng_atomic_int *);
NNG_DECL void nng_atomic_inc(nng_atomic_int *);
// nng_atomic_cas is a compare and swap. The second argument is the
// value to compare against, and the third is the new value. Returns
// true if the value was set.
NNG_DECL bool nng_atomic_cas(nng_atomic_int *, int, int);
// atomic pointers. We only support a few operations.
typedef struct nni_atomic_ptr nng_atomic_ptr;
NNG_DECL int nng_atomic_alloc_ptr(nng_atomic_ptr **v);
NNG_DECL void nng_atomic_free_ptr(nng_atomic_ptr *v);
NNG_DECL void nng_atomic_set_ptr(nng_atomic_ptr *, void *);
NNG_DECL void * nng_atomic_get_ptr(nng_atomic_ptr *);
#ifdef __cplusplus
}
#endif
#endif // NNG_SUPPLEMENTAL_UTIL_PLATFORM_H