- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly
For automated changes based on OAI PL v1.1:
perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml
The rest (cmake, files with missing license, cmake) manually.
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/*
|
|
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
|
*/
|
|
|
|
#ifndef LINEAR_ALLOC_H
|
|
#define LINEAR_ALLOC_H
|
|
|
|
#include <limits.h>
|
|
|
|
typedef unsigned int uid_t;
|
|
#define UID_LINEAR_ALLOCATOR_SIZE 1024
|
|
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((UID_LINEAR_ALLOCATOR_SIZE/8)/sizeof(unsigned int)) + 1)
|
|
typedef struct uid_linear_allocator_s {
|
|
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
|
|
} uid_allocator_t;
|
|
|
|
static inline void uid_linear_allocator_init(uid_allocator_t *uia) {
|
|
memset(uia, 0, sizeof(uid_allocator_t));
|
|
}
|
|
|
|
static inline uid_t uid_linear_allocator_new(uid_allocator_t *uia) {
|
|
unsigned int bit_index = 1;
|
|
uid_t uid = 0;
|
|
|
|
for (unsigned int i = 0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) {
|
|
if (uia->bitmap[i] != UINT_MAX) {
|
|
bit_index = 1;
|
|
uid = 0;
|
|
|
|
while ((uia->bitmap[i] & bit_index) == bit_index) {
|
|
bit_index = bit_index << 1;
|
|
uid += 1;
|
|
}
|
|
|
|
uia->bitmap[i] |= bit_index;
|
|
return uid + (i*sizeof(unsigned int)*8);
|
|
}
|
|
}
|
|
|
|
return UINT_MAX;
|
|
}
|
|
|
|
|
|
static inline void uid_linear_allocator_free(uid_allocator_t *uia, uid_t uid) {
|
|
const unsigned int i = uid/sizeof(unsigned int)/8;
|
|
const unsigned int bit = uid % (sizeof(unsigned int) * 8);
|
|
const unsigned int value = ~(1 << bit);
|
|
|
|
if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) {
|
|
uia->bitmap[i] &= value;
|
|
}
|
|
}
|
|
|
|
#endif /* LINEAR_ALLOC_H */
|