Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/shared/wlu_common.h
Views: 3959
/*1* Common code for wl routines2*3* $Copyright (C) 2002-2005 Broadcom Corporation$4*5* $Id: wlu_common.h 370210 2012-11-21 05:35:27Z nisar $6*/7#include <wlioctl.h>8#include <bcmutils.h>9#if defined(_CFE_)10#include <lib_types.h>11#include <lib_string.h>12#include <lib_printf.h>13#include <lib_malloc.h>14#include <cfe_error.h>15#elif defined(__IOPOS__)16#include <typedefs.h>17#include <bcmstdlib.h>18#include <bcmutils.h>19#else20#include <stdio.h>21#include <stdlib.h>22#include <string.h>23#include <ctype.h>24#include <assert.h>25#endif /* defined(_CFE_) */26#if defined (__NetBSD__) || defined(linux) || defined(MACOSX) || defined(EFI)27#define stricmp strcasecmp28#define strnicmp strncasecmp29#elif defined(vxworks) || defined(__ECOS)30extern int stricmp(const char *s1, const char *s2);31extern int strnicmp(const char *s1, const char *s2, size_t len);32#elif defined(UNDER_CE) || defined(_CRT_SECURE_NO_DEPRECATE)33#define stricmp _stricmp34#define strnicmp _strnicmp35#elif defined(_HNDRTE_)36#define stricmp strcmp37#define strnicmp strncmp38#elif defined(_CFE_)39#include <bcmutils.h>40#include <osl.h>41#define isalnum(c) bcm_isalnum(c)42#define isalpha(c) bcm_isalpha(c)43#define iscntrl(c) bcm_iscntrl(c)44#define isdigit(c) bcm_isdigit(c)45#define isgraph(c) bcm_isgraph(c)46#define islower(c) bcm_islower(c)47#define isprint(c) bcm_isprint(c)48#define ispunct(c) bcm_ispunct(c)49#define isspace(c) bcm_isspace(c)50#define isupper(c) bcm_isupper(c)51#define isxdigit(c) bcm_isxdigit(c)52#define stricmp(s1, s2) lib_strcmpi((s1), (s2))53#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))54#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))55#define fprintf(stream, fmt, args...) xprintf(fmt, ##args)56#define fputs(s, stream) puts(s)57#define malloc(size) KMALLOC((size), 0)58#define free(ptr) KFREE(ptr)59/* XXX Buggy implementations */60#define strnicmp(s1, s2, len) strncmp((s1), (s2), (len))61#define strspn(s, accept) (0)62#define strtol(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))63#elif defined(__IOPOS__)64#define fprintf(file, fmt, arg...) jtag_printf(fmt, ##arg)65#define fputs(s, stream) jtag_puts(s)66#define printf jtag_printf67#define stricmp strcmp68#define strnicmp strncmp69#define strtol(nptr, endptr, base) ((long)strtoul((nptr), (endptr), (base)))70#define tolower(c) bcm_tolower(c)71#define toupper(c) bcm_toupper(c)72#define islower(c) bcm_islower(c)73#define isprint(c) bcm_isprint(c)74#define isspace(c) bcm_isspace(c)75#define isupper(c) bcm_isupper(c)76#define isxdigit(c) bcm_isxdigit(c)77#define isdigit(c) bcm_isdigit(c)78#elif defined(BWL_STRICMP)79#define stricmp bcmstricmp80#define strnicmp bcmstrnicmp81#endif /* __NetBSD__ */828384/* IOCTL swapping mode for Big Endian host with Little Endian dongle. Default to off */85/* The below macros handle endian mis-matches between wl utility and wl driver. */86static bool g_swap = FALSE;87#define htod64(i) (g_swap?bcmswap64(i):(uint64)(i))88#define htod32(i) (g_swap?bcmswap32(i):(uint32)(i))89#define htod16(i) (g_swap?bcmswap16(i):(uint16)(i))90#define dtoh64(i) (g_swap?bcmswap64(i):(uint64)(i))91#define dtoh32(i) (g_swap?bcmswap32(i):(uint32)(i))92#define dtoh16(i) (g_swap?bcmswap16(i):(uint16)(i))93#define htodchanspec(i) (g_swap?htod16(i):i)94#define dtohchanspec(i) (g_swap?dtoh16(i):i)95#define htodenum(i) (g_swap?((sizeof(i) == 4) ? htod32(i) : ((sizeof(i) == 2) ? htod16(i) : i)):i)96#define dtohenum(i) (g_swap?((sizeof(i) == 4) ? dtoh32(i) : ((sizeof(i) == 2) ? htod16(i) : i)):i)9798/* command batching data structure */99typedef struct wl_seq_cmd_pkt {100struct wl_seq_cmd_pkt *next;101wl_seq_cmd_ioctl_t cmd_header;102char * data; /* user buffer */103} wl_seq_cmd_pkt_t;104105typedef struct wl_cmd_list {106wl_seq_cmd_pkt_t *head;107wl_seq_cmd_pkt_t *tail;108} wl_cmd_list_t;109110extern wl_cmd_list_t cmd_list;111extern int cmd_pkt_list_num;112extern bool cmd_batching_mode;113114extern int wlu_iovar_getbuf(void* wl, const char *iovar,115void *param, int paramlen, void *bufptr, int buflen);116extern int wlu_iovar_setbuf(void* wl, const char *iovar,117void *param, int paramlen, void *bufptr, int buflen);118extern int wlu_var_setbuf(void *wl, const char *iovar, void *param, int param_len);119extern int wlu_iovar_getint(void *wl, const char *iovar, int *pval);120extern void init_cmd_batchingmode(void);121extern void clean_up_cmd_list(void);122extern int wl_check(void *wl);123124extern int add_one_batched_cmd(int cmd, void *cmdbuf, int len);125extern int wlu_get_req_buflen(int cmd, void *cmdbuf, int len);126extern int wlu_get(void *wl, int cmd, void *cmdbuf, int len);127extern int wlu_set(void *wl, int cmd, void *cmdbuf, int len);128extern int wlu_iovar_get(void *wl, const char *iovar, void *outbuf, int len);129extern int wlu_iovar_set(void *wl, const char *iovar, void *param, int paramlen);130extern int wlu_iovar_getint(void *wl, const char *iovar, int *pval);131extern int wlu_iovar_setint(void *wl, const char *iovar, int val);132133134