Skip to content

Commit 9b0e064

Browse files
committed
[mk][migration] Add lk_|Lk prefix to avoid symbol clash during migration
1 parent 4b8debb commit 9b0e064

File tree

14 files changed

+80
-80
lines changed

14 files changed

+80
-80
lines changed

mk/app/tests/thread_tests.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,14 @@ static void spinlock_test(void) {
601601
printf("seems to work\n");
602602

603603
#define COUNT (1024 * 1024)
604-
arch_interrupt_save(&state, SPIN_LOCK_FLAG_INTERRUPTS);
604+
lk_arch_interrupt_save(&state, SPIN_LOCK_FLAG_INTERRUPTS);
605605
uint32_t c = arch_cycle_count();
606606
for (uint i = 0; i < COUNT; i++) {
607607
spin_lock(&lock);
608608
spin_unlock(&lock);
609609
}
610610
c = arch_cycle_count() - c;
611-
arch_interrupt_restore(state, SPIN_LOCK_FLAG_INTERRUPTS);
611+
lk_arch_interrupt_restore(state, SPIN_LOCK_FLAG_INTERRUPTS);
612612

613613
printf("%u cycles to acquire/release lock %u times (%u cycles per)\n", c, COUNT, c / COUNT);
614614

mk/arch/x86/include/arch/arch_ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ static inline ulong arch_cycle_count(void) {
5252
/* use a global pointer to store the current_thread */
5353
extern struct thread *_current_thread;
5454

55-
static inline struct thread *arch_get_current_thread(void) { return _current_thread; }
55+
static inline struct thread *lk_arch_get_current_thread(void) { return _current_thread; }
5656

57-
static inline void arch_set_current_thread(struct thread *t) { _current_thread = t; }
57+
static inline void lk_arch_set_current_thread(struct thread *t) { _current_thread = t; }
5858

59-
static inline uint arch_curr_cpu_num(void) { return 0; }
59+
static inline uint lk_arch_curr_cpu_num(void) { return 0; }
6060

6161
#if ARCH_X86_64
6262
// relies on SSE2

mk/arch/x86/include/arch/spinlock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ typedef x86_flags_t spin_lock_saved_state_t;
2121
typedef uint spin_lock_save_flags_t;
2222

2323
/* simple implementation of spinlocks for no smp support */
24-
static inline void arch_spin_lock_init(spin_lock_t *lock) { *lock = SPIN_LOCK_INITIAL_VALUE; }
24+
static inline void lk_arch_spin_lock_init(spin_lock_t *lock) { *lock = SPIN_LOCK_INITIAL_VALUE; }
2525

26-
static inline bool arch_spin_lock_held(spin_lock_t *lock) { return *lock != 0; }
26+
static inline bool lk_arch_spin_lock_held(spin_lock_t *lock) { return *lock != 0; }
2727

28-
static inline void arch_spin_lock(spin_lock_t *lock) { *lock = 1; }
28+
static inline void lk_arch_spin_lock(spin_lock_t *lock) { *lock = 1; }
2929

30-
static inline int arch_spin_trylock(spin_lock_t *lock) { return 0; }
30+
static inline int lk_arch_spin_trylock(spin_lock_t *lock) { return 0; }
3131

32-
static inline void arch_spin_unlock(spin_lock_t *lock) { *lock = 0; }
32+
static inline void lk_arch_spin_unlock(spin_lock_t *lock) { *lock = 0; }
3333

3434
/* flags are unused on x86 */
3535
#define ARCH_DEFAULT_SPIN_LOCK_FLAG_INTERRUPTS 0
3636

37-
static inline void arch_interrupt_save(spin_lock_saved_state_t *statep,
38-
spin_lock_save_flags_t flags) {
37+
static inline void lk_arch_interrupt_save(spin_lock_saved_state_t *statep,
38+
spin_lock_save_flags_t flags) {
3939
*statep = x86_save_flags();
4040
arch_disable_ints();
4141
}
4242

43-
static inline void arch_interrupt_restore(spin_lock_saved_state_t old_state,
44-
spin_lock_save_flags_t flags) {
43+
static inline void lk_arch_interrupt_restore(spin_lock_saved_state_t old_state,
44+
spin_lock_save_flags_t flags) {
4545
x86_restore_flags(old_state);
4646
}
4747

mk/dev/bus/pci/pci.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// Largely C level api for the PCI bus manager
2424

2525
namespace {
26-
SpinLock lock;
26+
LkSpinLock lock;
2727
pci_backend *pcib = nullptr;
2828
} // namespace
2929

@@ -45,7 +45,7 @@ status_t pci_read_config_byte(const pci_location_t state, uint32_t reg, uint8_t
4545
if (!pcib)
4646
return ERR_NOT_CONFIGURED;
4747

48-
AutoSpinLock guard(&lock);
48+
LkAutoSpinLock guard(&lock);
4949

5050
int res = pcib->read_config_byte(state, reg, value);
5151

@@ -55,7 +55,7 @@ status_t pci_read_config_half(const pci_location_t state, uint32_t reg, uint16_t
5555
if (!pcib)
5656
return ERR_NOT_CONFIGURED;
5757

58-
AutoSpinLock guard(&lock);
58+
LkAutoSpinLock guard(&lock);
5959

6060
int res = pcib->read_config_half(state, reg, value);
6161

@@ -66,7 +66,7 @@ status_t pci_read_config_word(const pci_location_t state, uint32_t reg, uint32_t
6666
if (!pcib)
6767
return ERR_NOT_CONFIGURED;
6868

69-
AutoSpinLock guard(&lock);
69+
LkAutoSpinLock guard(&lock);
7070

7171
int res = pcib->read_config_word(state, reg, value);
7272

@@ -77,7 +77,7 @@ status_t pci_write_config_byte(const pci_location_t state, uint32_t reg, uint8_t
7777
if (!pcib)
7878
return ERR_NOT_CONFIGURED;
7979

80-
AutoSpinLock guard(&lock);
80+
LkAutoSpinLock guard(&lock);
8181

8282
int res = pcib->write_config_byte(state, reg, value);
8383

@@ -88,7 +88,7 @@ status_t pci_write_config_half(const pci_location_t state, uint32_t reg, uint16_
8888
if (!pcib)
8989
return ERR_NOT_CONFIGURED;
9090

91-
AutoSpinLock guard(&lock);
91+
LkAutoSpinLock guard(&lock);
9292

9393
int res = pcib->write_config_half(state, reg, value);
9494

@@ -99,7 +99,7 @@ status_t pci_write_config_word(const pci_location_t state, uint32_t reg, uint32_
9999
if (!pcib)
100100
return ERR_NOT_CONFIGURED;
101101

102-
AutoSpinLock guard(&lock);
102+
LkAutoSpinLock guard(&lock);
103103

104104
int res = pcib->write_config_word(state, reg, value);
105105

mk/dev/net/e1000/e1000.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ handler_return e1000::irq_handler() {
166166

167167
LTRACEF("icr %#x\n", icr);
168168

169-
AutoSpinLockNoIrqSave guard(&lock_);
169+
LkAutoSpinLockNoIrqSave guard(&lock_);
170170

171171
handler_return ret = INT_NO_RESCHEDULE;
172172

@@ -237,7 +237,7 @@ int e1000::rx_worker_routine() {
237237
pktbuf_t *p;
238238

239239
{
240-
AutoSpinLock guard(&lock_);
240+
LkAutoSpinLock guard(&lock_);
241241

242242
p = list_remove_head_type(&rx_queue_, pktbuf_t, list);
243243
}
@@ -313,7 +313,7 @@ void e1000::add_pktbuf_to_rxring_locked(pktbuf_t *p) {
313313
}
314314

315315
void e1000::add_pktbuf_to_rxring(pktbuf_t *pkt) {
316-
AutoSpinLock guard(&lock_);
316+
LkAutoSpinLock guard(&lock_);
317317

318318
add_pktbuf_to_rxring_locked(pkt);
319319
}

mk/kernel/include/kernel/mutex.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ __END_CDECLS
5757
#include <fbl/macros.h>
5858

5959
// C++ wrapper object
60-
class Mutex {
60+
class LkMutex {
6161
public:
62-
constexpr Mutex() = default;
63-
~Mutex() { mutex_destroy(&lock_); }
62+
constexpr LkMutex() = default;
63+
~LkMutex() { mutex_destroy(&lock_); }
6464

6565
status_t acquire(lk_time_t timeout = INFINITE_TIME) {
6666
return mutex_acquire_timeout(&lock_, timeout);
@@ -69,25 +69,25 @@ class Mutex {
6969
bool is_held() { return is_mutex_held(&lock_); }
7070

7171
// suppress default constructors
72-
DISALLOW_COPY_ASSIGN_AND_MOVE(Mutex);
72+
DISALLOW_COPY_ASSIGN_AND_MOVE(LkMutex);
7373

7474
private:
7575
mutex_t lock_ = MUTEX_INITIAL_VALUE(lock_);
7676

77-
// AutoLock has access to the inner lock
78-
friend class AutoLock;
77+
// LkAutoLock has access to the inner lock
78+
friend class LkAutoLock;
7979
};
8080

8181
// RAII wrapper around the mutex
82-
class AutoLock {
82+
class LkAutoLock {
8383
public:
84-
explicit AutoLock(mutex_t *mutex) : mutex_(mutex) { mutex_acquire(mutex_); }
85-
AutoLock(mutex_t &mutex) : AutoLock(&mutex) {}
84+
explicit LkAutoLock(mutex_t *mutex) : mutex_(mutex) { mutex_acquire(mutex_); }
85+
LkAutoLock(mutex_t &mutex) : LkAutoLock(&mutex) {}
8686

87-
explicit AutoLock(Mutex *mutex) : AutoLock(&mutex->lock_) {}
88-
AutoLock(Mutex &mutex) : AutoLock(&mutex) {}
87+
explicit LkAutoLock(LkMutex *mutex) : LkAutoLock(&mutex->lock_) {}
88+
LkAutoLock(LkMutex &mutex) : LkAutoLock(&mutex) {}
8989

90-
~AutoLock() { release(); }
90+
~LkAutoLock() { release(); }
9191

9292
// early release the mutex before the object goes out of scope
9393
void release() {
@@ -98,7 +98,7 @@ class AutoLock {
9898
}
9999

100100
// suppress default constructors
101-
DISALLOW_COPY_ASSIGN_AND_MOVE(AutoLock);
101+
DISALLOW_COPY_ASSIGN_AND_MOVE(LkAutoLock);
102102

103103
private:
104104
mutex_t *mutex_ = nullptr;

mk/kernel/include/kernel/spinlock.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
__BEGIN_CDECLS
1515

1616
/* interrupts should already be disabled */
17-
static inline void spin_lock(spin_lock_t *lock) { arch_spin_lock(lock); }
17+
static inline void spin_lock(spin_lock_t *lock) { lk_arch_spin_lock(lock); }
1818

1919
/* Returns 0 on success, non-0 on failure */
20-
static inline int spin_trylock(spin_lock_t *lock) { return arch_spin_trylock(lock); }
20+
static inline int spin_trylock(spin_lock_t *lock) { return lk_arch_spin_trylock(lock); }
2121

2222
/* interrupts should already be disabled */
23-
static inline void spin_unlock(spin_lock_t *lock) { arch_spin_unlock(lock); }
23+
static inline void spin_unlock(spin_lock_t *lock) { lk_arch_spin_unlock(lock); }
2424

25-
static inline void spin_lock_init(spin_lock_t *lock) { arch_spin_lock_init(lock); }
25+
static inline void spin_lock_init(spin_lock_t *lock) { lk_arch_spin_lock_init(lock); }
2626

27-
static inline bool spin_lock_held(spin_lock_t *lock) { return arch_spin_lock_held(lock); }
27+
static inline bool spin_lock_held(spin_lock_t *lock) { return lk_arch_spin_lock_held(lock); }
2828

2929
/* spin lock irq save flags: */
3030

@@ -40,15 +40,15 @@ static inline bool spin_lock_held(spin_lock_t *lock) { return arch_spin_lock_hel
4040
/* same as spin lock, but save disable and save interrupt state first */
4141
static inline void spin_lock_save(spin_lock_t *lock, spin_lock_saved_state_t *statep,
4242
spin_lock_save_flags_t flags) {
43-
arch_interrupt_save(statep, flags);
43+
lk_arch_interrupt_save(statep, flags);
4444
spin_lock(lock);
4545
}
4646

4747
/* restore interrupt state before unlocking */
4848
static inline void spin_unlock_restore(spin_lock_t *lock, spin_lock_saved_state_t old_state,
4949
spin_lock_save_flags_t flags) {
5050
spin_unlock(lock);
51-
arch_interrupt_restore(old_state, flags);
51+
lk_arch_interrupt_restore(old_state, flags);
5252
}
5353

5454
/* hand(ier) routines */
@@ -65,10 +65,10 @@ __END_CDECLS
6565
#include <fbl/macros.h>
6666

6767
// C++ wrapper around a C spinlock_t
68-
class SpinLock {
68+
class LkSpinLock {
6969
public:
70-
constexpr SpinLock() = default;
71-
~SpinLock() { DEBUG_ASSERT(!is_held()); }
70+
constexpr LkSpinLock() = default;
71+
~LkSpinLock() { DEBUG_ASSERT(!is_held()); }
7272

7373
void lock() { spin_lock(&lock_); }
7474
int trylock() { return spin_trylock(&lock_); }
@@ -84,22 +84,22 @@ class SpinLock {
8484
}
8585

8686
// suppress default constructors
87-
DISALLOW_COPY_ASSIGN_AND_MOVE(SpinLock);
87+
DISALLOW_COPY_ASSIGN_AND_MOVE(LkSpinLock);
8888

8989
private:
9090
spin_lock_t lock_ = SPIN_LOCK_INITIAL_VALUE;
9191

9292
// friend classes to get to the inner lock
93-
friend class AutoSpinLock;
94-
friend class AutoSpinLockNoIrqSave;
93+
friend class LkAutoSpinLock;
94+
friend class LkAutoSpinLockNoIrqSave;
9595
};
9696

9797
// RAII wrappers for a spinlock, with and without IRQ Save
98-
class AutoSpinLock {
98+
class LkAutoSpinLock {
9999
public:
100-
explicit AutoSpinLock(spin_lock_t *lock) : lock_(lock) { spin_lock_irqsave(lock_, state_); }
101-
explicit AutoSpinLock(SpinLock *lock) : AutoSpinLock(&lock->lock_) {}
102-
~AutoSpinLock() { release(); }
100+
explicit LkAutoSpinLock(spin_lock_t *lock) : lock_(lock) { spin_lock_irqsave(lock_, state_); }
101+
explicit LkAutoSpinLock(LkSpinLock *lock) : LkAutoSpinLock(&lock->lock_) {}
102+
~LkAutoSpinLock() { release(); }
103103

104104
void release() {
105105
if (likely(lock_)) {
@@ -109,18 +109,18 @@ class AutoSpinLock {
109109
}
110110

111111
// suppress default constructors
112-
DISALLOW_COPY_ASSIGN_AND_MOVE(AutoSpinLock);
112+
DISALLOW_COPY_ASSIGN_AND_MOVE(LkAutoSpinLock);
113113

114114
private:
115115
spin_lock_t *lock_;
116116
spin_lock_saved_state_t state_;
117117
};
118118

119-
class AutoSpinLockNoIrqSave {
119+
class LkAutoSpinLockNoIrqSave {
120120
public:
121-
explicit AutoSpinLockNoIrqSave(spin_lock_t *lock) : lock_(lock) { spin_lock(lock_); }
122-
explicit AutoSpinLockNoIrqSave(SpinLock *lock) : AutoSpinLockNoIrqSave(&lock->lock_) {}
123-
~AutoSpinLockNoIrqSave() { release(); }
121+
explicit LkAutoSpinLockNoIrqSave(spin_lock_t *lock) : lock_(lock) { spin_lock(lock_); }
122+
explicit LkAutoSpinLockNoIrqSave(LkSpinLock *lock) : LkAutoSpinLockNoIrqSave(&lock->lock_) {}
123+
~LkAutoSpinLockNoIrqSave() { release(); }
124124

125125
void release() {
126126
if (likely(lock_)) {
@@ -130,7 +130,7 @@ class AutoSpinLockNoIrqSave {
130130
}
131131

132132
// suppress default constructors
133-
DISALLOW_COPY_ASSIGN_AND_MOVE(AutoSpinLockNoIrqSave);
133+
DISALLOW_COPY_ASSIGN_AND_MOVE(LkAutoSpinLockNoIrqSave);
134134

135135
private:
136136
spin_lock_t *lock_;

mk/kernel/include/kernel/thread.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ struct timer;
200200
enum handler_return thread_timer_tick(struct timer *, lk_time_t now, void *arg);
201201

202202
/* the current thread */
203-
static inline thread_t *get_current_thread(void) { return arch_get_current_thread(); }
203+
static inline thread_t *get_current_thread(void) { return lk_arch_get_current_thread(); }
204204

205-
static inline void set_current_thread(thread_t *t) { arch_set_current_thread(t); }
205+
static inline void set_current_thread(thread_t *t) { lk_arch_set_current_thread(t); }
206206

207207
/* list of all threads, unsafe to traverse without holding thread_lock */
208208
extern struct list_node thread_list;
@@ -254,9 +254,9 @@ struct thread_stats {
254254

255255
extern struct thread_stats thread_stats[SMP_MAX_CPUS];
256256

257-
#define THREAD_STATS_INC(name) \
258-
do { \
259-
thread_stats[arch_curr_cpu_num()].name++; \
257+
#define THREAD_STATS_INC(name) \
258+
do { \
259+
thread_stats[lk_arch_curr_cpu_num()].name++; \
260260
} while (0)
261261

262262
#else

0 commit comments

Comments
 (0)