Hanhui
9 years ago
8 changed files with 461 additions and 2 deletions
@ -0,0 +1,39 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_BLIB_H |
|||
#define __VXWORKS_BLIB_H |
|||
|
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
int bcmp(char *buf1, char *buf2, size_t nbytes); |
|||
void binvert(char *buf, size_t nbytes); |
|||
void bswap(char *buf1, char *buf2, size_t nbytes); |
|||
void swab(char *source, char *destination, size_t nbytes); |
|||
void uswab(char *source, char *destination, size_t nbytes); |
|||
void bcopyBytes(char *source, char *destination, size_t nbytes); |
|||
void bcopyWords(char *source, char *destination, size_t nwords); |
|||
void bcopyLongs(char *source, char *destination, size_t nlongs); |
|||
void bcopyQuads(char *source, char *destination, size_t nquads); |
|||
void bfill(char *buf, size_t nbytes, int ch); |
|||
void bfillBytes(char *buf, size_t nbytes, int ch); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* __VXWORKS_BLIB_H */ |
@ -0,0 +1,24 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_CPUSET_H |
|||
#define __VXWORKS_CPUSET_H |
|||
|
|||
#include "vxWorksCommon.h" |
|||
#include "vxCpuLib.h" |
|||
|
|||
#define CPUSET_SET(p, n) LW_CPU_SET(n, p) |
|||
#define CPUSET_CLR(p, n) LW_CPU_CLR(n, p) |
|||
#define CPUSET_ISSET(p, n) LW_CPU_ISSET(n, p) |
|||
#define CPUSET_ZERO(p) LW_CPU_ZERO(p) |
|||
|
|||
#endif /* __VXWORKS_CPUSET_H */ |
@ -0,0 +1,85 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_FFSLIB_H |
|||
#define __VXWORKS_FFSLIB_H |
|||
|
|||
#include "vxWorksCommon.h" |
|||
|
|||
#define ffsLsb archFindLsb |
|||
#define ffsMsb archFindMsb |
|||
#define ffs32Lsb archFindLsb |
|||
#define ffs32Msb archFindMsb |
|||
|
|||
#define ffsLsb_autosize(i) ((sizeof(i) == 8) ? ffs64Lsb(i) : ffs32Lsb(i)) |
|||
#define ffsMsb_autosize(i) ((sizeof(i) == 8) ? ffs64Msb(i) : ffs32Msb(i)) |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
extern int archFindLsb(UINT32 ui32); |
|||
extern int archFindMsb(UINT32 ui32); |
|||
|
|||
static inline int ffs64Msb (UINT64 i) |
|||
{ |
|||
union { |
|||
UINT64 qword; |
|||
UINT32 dwords[2]; |
|||
} i_u; |
|||
|
|||
i_u.qword = i; |
|||
|
|||
#if _BYTE_ORDER == _BIG_ENDIAN |
|||
if (i_u.dwords[0]) { |
|||
return ffsMsb(i_u.dwords[0]) + 32; |
|||
} else { |
|||
return ffsMsb(i_u.dwords[1]); |
|||
} |
|||
#else |
|||
if (i_u.dwords[1]) { |
|||
return ffsMsb(i_u.dwords[1]) + 32; |
|||
} else { |
|||
return ffsMsb(i_u.dwords[0]); |
|||
} |
|||
#endif /* _BYTE_ORDER */ |
|||
} |
|||
|
|||
static inline int ffs64Lsb (UINT64 i) |
|||
{ |
|||
union { |
|||
UINT64 qword; |
|||
UINT32 dwords[2]; |
|||
} i_u; |
|||
|
|||
i_u.qword = i; |
|||
|
|||
#if _BYTE_ORDER == _BIG_ENDIAN |
|||
if (i_u.dwords[1]) { |
|||
return ffsLsb(i_u.dwords[1]); |
|||
} else { |
|||
return ffsLsb(i_u.dwords[0]) + (i ? 32 : 0); |
|||
} |
|||
#else |
|||
if (i_u.dwords[0]) { |
|||
return ffsLsb(i_u.dwords[0]); |
|||
} else { |
|||
return ffsLsb(i_u.dwords[1]) + (i ? 32 : 0); |
|||
} |
|||
#endif /* _BYTE_ORDER */ |
|||
} |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* __VXWORKS_FFSLIB_H */ |
@ -0,0 +1,18 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_HASHLIB_H |
|||
#define __VXWORKS_HASHLIB_H |
|||
|
|||
#error "hashLib not support Now!" |
|||
|
|||
#endif /* __VXWORKS_HASHLIB_H */ |
@ -0,0 +1,23 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_LOGINLIB_H |
|||
#define __VXWORKS_LOGINLIB_H |
|||
|
|||
#include <shadow.h> |
|||
#include "vxWorksCommon.h" |
|||
|
|||
#define loginUserVerify(n, p) userlogin(n, p, 1) |
|||
|
|||
#define |
|||
|
|||
#endif /* __VXWORKS_LOGINLIB_H */ |
@ -0,0 +1,269 @@ |
|||
/**
|
|||
* @file |
|||
* errno library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#include <stddef.h> |
|||
#include <SylixOS.h> |
|||
|
|||
/*
|
|||
* bcmp - compare one buffer to another |
|||
*/ |
|||
int bcmp (char *buf1, char *buf2, size_t nbytes) |
|||
{ |
|||
unsigned char *p1; |
|||
unsigned char *p2; |
|||
|
|||
if (nbytes == 0) { |
|||
return (0); |
|||
} |
|||
|
|||
p1 = (unsigned char *)buf1; |
|||
p2 = (unsigned char *)buf2; |
|||
|
|||
while (*p1++ == *p2++) { |
|||
if (--nbytes == 0) { |
|||
return (0); |
|||
} |
|||
} |
|||
|
|||
return ((*--p1) - (*--p2)); |
|||
} |
|||
|
|||
/*
|
|||
* binvert - invert the order of bytes in a buffer |
|||
*/ |
|||
void binvert (char *buf, size_t nbytes) |
|||
{ |
|||
char *buf_end = buf + nbytes - 1; |
|||
char temp; |
|||
|
|||
while (buf < buf_end) { |
|||
temp = *buf; |
|||
*buf = *buf_end; |
|||
*buf_end = temp; |
|||
|
|||
buf_end--; |
|||
buf++; |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bswap - swap buffers |
|||
*/ |
|||
void bswap (char *buf1, char *buf2, size_t nbytes) |
|||
{ |
|||
char temp; |
|||
|
|||
while (nbytes >= 1) { |
|||
temp = *buf1; |
|||
*buf1++ = *buf2; |
|||
*buf2++ = temp; |
|||
nbytes--; |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* swab - swap bytes |
|||
*/ |
|||
void swab (char *source, char *destination, size_t nbytes) |
|||
{ |
|||
unsigned short *src = (unsigned short *)source; |
|||
unsigned short *dst = (unsigned short *)destination; |
|||
unsigned short *dst_end = (unsigned short *)(destination + nbytes); |
|||
|
|||
for (; dst < dst_end; dst++, src++) { |
|||
*dst = (short)(((*src & 0x00ff) << 8) | ((*src & 0xff00) >> 8)); |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* uswab - swap bytes with buffers that are not necessarily aligned |
|||
*/ |
|||
void uswab (char *source, char *destination, size_t nbytes) |
|||
{ |
|||
char *dst = (char *)destination; |
|||
char *dst_end = dst + nbytes; |
|||
char byte1; |
|||
char byte2; |
|||
|
|||
while (dst < dst_end) { |
|||
byte1 = *source++; |
|||
byte2 = *source++; |
|||
*dst++ = byte2; |
|||
*dst++ = byte1; |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bcopyBytes - copy one buffer to another one byte (8 bits) at a time |
|||
*/ |
|||
void bcopyBytes (char *source, char *destination, size_t nbytes) |
|||
{ |
|||
char *dstend; |
|||
size_t offset = (size_t)(destination - source); |
|||
|
|||
if (offset == 0) { |
|||
return; |
|||
} |
|||
|
|||
if (offset >= nbytes) { /* true also when destination < source if no wrap */ |
|||
/*
|
|||
* forward copy |
|||
*/ |
|||
dstend = destination + nbytes; |
|||
while (destination != dstend) { |
|||
*destination++ = *source++; |
|||
} |
|||
} else { |
|||
/*
|
|||
* backward copy |
|||
*/ |
|||
dstend = destination; |
|||
destination += nbytes; |
|||
source += nbytes; |
|||
|
|||
while (destination != dstend) { |
|||
*--destination = *--source; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bcopyWords - copy one buffer to another one word (16 bits) at a time |
|||
*/ |
|||
void bcopyWords (char *source, char *destination, size_t nwords) |
|||
{ |
|||
short *dstend; |
|||
short *src = (short *)source; |
|||
short *dst = (short *)destination; |
|||
size_t nbytes = nwords << 1; /* convert to bytes */ |
|||
size_t offset = (size_t)(destination - source); |
|||
|
|||
if (offset == 0) { |
|||
return; |
|||
} |
|||
|
|||
if (offset >= nbytes) { /* true also when destination < source if no wrap */ |
|||
/*
|
|||
* forward copy |
|||
*/ |
|||
dstend = dst + nwords; |
|||
while (dst != dstend) { |
|||
*dst++ = *src++; |
|||
} |
|||
} else { |
|||
/*
|
|||
* backward copy |
|||
*/ |
|||
dstend = dst; |
|||
dst += nwords; |
|||
src += nwords; |
|||
while (dst != dstend) { |
|||
*--dst = *--src; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bcopyLongs - copy one buffer to another one long word (32 bits) at a time |
|||
*/ |
|||
void bcopyLongs (char *source, char *destination, size_t nlongs) |
|||
{ |
|||
UINT32 *dstend; |
|||
UINT32 *src = (UINT32 *)source; |
|||
UINT32 *dst = (UINT32 *)destination; |
|||
size_t nbytes = nlongs * sizeof(UINT32); /* convert to bytes */ |
|||
size_t offset = (size_t)(destination - source); |
|||
|
|||
if (offset == 0) { |
|||
return; |
|||
} |
|||
|
|||
if (offset >= nbytes) { /* true also when destination < source if no wrap */ |
|||
/*
|
|||
* forward copy |
|||
*/ |
|||
dstend = dst + nlongs; |
|||
while (dst != dstend) { |
|||
*dst++ = *src++; |
|||
} |
|||
} else { |
|||
/*
|
|||
* backward copy |
|||
*/ |
|||
dstend = dst; |
|||
dst += nlongs; |
|||
src += nlongs; |
|||
while (dst != dstend) { |
|||
*--dst = *--src; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bcopyQuads - copy one buffer to another quad word (64 bits) at a time (64-bit) |
|||
*/ |
|||
void bcopyQuads (char *source, char *destination, size_t nquads) |
|||
{ |
|||
UINT64 *dstend; |
|||
UINT64 *src = (UINT64 *)source; |
|||
UINT64 *dst = (UINT64 *)destination; |
|||
size_t nbytes = nquads * sizeof(UINT64); /* convert to bytes */ |
|||
size_t offset = (size_t)(destination - source); |
|||
|
|||
if (offset == 0) { |
|||
return; |
|||
} |
|||
|
|||
if (offset >= nbytes) { /* true also when destination < source if no wrap */ |
|||
/*
|
|||
* forward copy |
|||
*/ |
|||
dstend = dst + nquads; |
|||
while (dst != dstend) { |
|||
*dst++ = *src++; |
|||
} |
|||
} else { |
|||
/*
|
|||
* backward copy |
|||
*/ |
|||
dstend = dst; |
|||
dst += nquads; |
|||
src += nquads; |
|||
while (dst != dstend) { |
|||
*--dst = *--src; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* bfill - fill a buffer with a specified character |
|||
*/ |
|||
void bfill (char *buf, size_t nbytes, int ch) |
|||
{ |
|||
lib_memset(buf, ch, nbytes); |
|||
} |
|||
|
|||
/*
|
|||
* bfillBytes - fill buffer with a specified character one byte at a time |
|||
*/ |
|||
void bfillBytes (char *buf, size_t nbytes, int ch) |
|||
{ |
|||
char *bufend = buf + nbytes; |
|||
|
|||
while (buf != bufend) { |
|||
*buf++ = (char)ch; |
|||
} |
|||
} |
|||
|
|||
/*
|
|||
* end |
|||
*/ |
Loading…
Reference in new issue