mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-21 00:06:32 +00:00
new:kzalloc
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define __force __attribute__((force))
|
||||
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
|
8
kernel/common/gfp.h
Normal file
8
kernel/common/gfp.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <common/sys/types.h>
|
||||
#include <common/compiler.h>
|
||||
/**
|
||||
* __GFP_ZERO: 获取内存的同时,将获取到的这块内存清空
|
||||
*
|
||||
*/
|
||||
#define __GFP_ZERO ((gfp_t)(1UL << 0))
|
@ -37,14 +37,14 @@ void mutex_lock(mutex_t *lock)
|
||||
spin_lock(&lock->wait_lock);
|
||||
if (likely(mutex_is_locked(lock)))
|
||||
{
|
||||
struct mutex_waiter_t *waiter = (struct mutex_waiter_t *)kmalloc(sizeof(struct mutex_waiter_t), 0);
|
||||
struct mutex_waiter_t *waiter = (struct mutex_waiter_t *)kzalloc(sizeof(struct mutex_waiter_t), 0);
|
||||
if (waiter == NULL)
|
||||
{
|
||||
kerror("In mutex_lock: no memory to alloc waiter. Program's behaviour might be indetermined!");
|
||||
spin_unlock(&lock->wait_lock);
|
||||
return;
|
||||
}
|
||||
memset(waiter, 0, sizeof(struct mutex_waiter_t));
|
||||
// memset(waiter, 0, sizeof(struct mutex_waiter_t));
|
||||
waiter->pcb = current_pcb;
|
||||
list_init(&waiter->list);
|
||||
list_append(&lock->wait_list, &waiter->list);
|
||||
|
@ -83,4 +83,6 @@ typedef struct __pthread_spinlock_t
|
||||
typedef struct __pthread_condattr_t
|
||||
{
|
||||
int clockid; // clockid_t
|
||||
} pthread_condattr_t;
|
||||
} pthread_condattr_t;
|
||||
|
||||
typedef uint64_t gfp_t;
|
Reference in New Issue
Block a user