1.5 KiB
1.5 KiB
LeOS Coding Style
Files names
- Only lower case
- Words separated with underscore:
aarch64/aarch64_boot.S
Preprocessor macro constants
- Only upper case
- Words separated with underscore:
#define AARCH64_CORE0_TIMER_IRQCTL (*((uint32_t *) 0x40000040))
Types
- Camel case started from upper case
- Do not typedef transparent structures
- Members of structre should be named in camel case started from lower case
struct Task {
void *sp;
void *stackStart;
uint32_t pid;
uint32_t stackSize;
uint32_t lock;
uint32_t counter;
uint32_t cycles;
int32_t priority;
uint32_t state;
char name[CONFIG_TASK_MAX_NAME_LEN + 1];
struct Task *next;
};
Constants and variables
- Global constants and variablesmust be prefixed with
g_
- Module (static) constants and variable must be prefixed
m_
- Camel case
static struct Task *m_currentTask = NULL;
Functions
- Camel case
- Prefix separated from function identifier by underscore
- Static functions may have no prefix
- Prefix always starts from capital letter
- Function identifier always starts from lower case verb
unsigned int
AArch64_getEL(void);
static struct Task *
scheduleNext(void);
Namespaces and prefixes
- Due to C has no native namespaces, prefixes should always be used
- Prefix should match with file name
/* file : task.h */
void
Task_initSheduler(void);