Skip to content

Commit

Permalink
Start renaming Boost to Hoost
Browse files Browse the repository at this point in the history
Summary:
- Rename the name using a pre-processor define.
- Rename the `xxx_fcontext()` globals to `hoost_xxx_fcontext()`.

Differential Revision: D66799412
  • Loading branch information
tmikov authored and facebook-github-bot committed Dec 6, 2024
1 parent 6d62f45 commit d554ed8
Show file tree
Hide file tree
Showing 90 changed files with 565 additions and 563 deletions.
2 changes: 2 additions & 0 deletions external/boost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ bz2.
`boost/context/fiber_fcontext.hpp`.
6. Minimal updates to `libs/context/CMakeLists.txt` to remove other library
dependencies, remove library alias, support `CMAKE_OSX_ARCHITECTURES`
7. Rename the `boost` namespace to `hoost` using a preprocessor define.
8. Rename the `xxx_fcontext()` globals to have a `hoost_` prefix.
3 changes: 3 additions & 0 deletions external/boost/boost_1_86_0/boost/config/user.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
// to ensure the correct libraries are selected at link time.
// #define BOOST_LIB_BUILDID amd64

// Rename boost to hoost to avoid conflicts
#define boost hoost

#if !defined(__EXCEPTIONS) && !defined(_CPPUNWIND)
#define HOOST_EXCEPTIONS_DISABLED
#endif
7 changes: 3 additions & 4 deletions external/boost/boost_1_86_0/boost/context/detail/fcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ struct transfer_t {
};

extern "C" BOOST_CONTEXT_DECL
transfer_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t const to, void * vp);
transfer_t BOOST_CONTEXT_CALLDECL hoost_jump_fcontext( fcontext_t const to, void * vp);
extern "C" BOOST_CONTEXT_DECL
fcontext_t BOOST_CONTEXT_CALLDECL make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
fcontext_t BOOST_CONTEXT_CALLDECL hoost_make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );

// based on an idea of Giovanni Derreta
extern "C" BOOST_CONTEXT_DECL
transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );
transfer_t BOOST_CONTEXT_CALLDECL hoost_ontop_fcontext( fcontext_t const to, void * vp, transfer_t (* fn)( transfer_t) );

}}}

Expand All @@ -43,4 +43,3 @@ transfer_t BOOST_CONTEXT_CALLDECL ontop_fcontext( fcontext_t const to, void * vp
#endif

#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_H

22 changes: 11 additions & 11 deletions external/boost/boost_1_86_0/boost/context/fiber_fcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void fiber_entry( transfer_t t) noexcept {
try {
#endif
// jump back to `create_context()`
t = jump_fcontext( t.fctx, nullptr);
t = hoost_jump_fcontext( t.fctx, nullptr);
// start executing
t.fctx = rec->run( t.fctx);
#ifndef HOOST_EXCEPTIONS_DISABLED
Expand All @@ -107,7 +107,7 @@ void fiber_entry( transfer_t t) noexcept {
#endif
BOOST_ASSERT( nullptr != t.fctx);
// destroy context-stack of `this`context on next context
ontop_fcontext( t.fctx, rec, fiber_exit< Rec >);
hoost_ontop_fcontext( t.fctx, rec, fiber_exit< Rec >);
BOOST_ASSERT_MSG( false, "context already terminated");
}

Expand Down Expand Up @@ -200,18 +200,18 @@ fcontext_t create_fiber1( StackAlloc && salloc, Fn && fn) {
void *ss_base = (void *)syscall(__NR_map_shadow_stack, 0, ss_size, SHADOW_STACK_SET_TOKEN);
BOOST_ASSERT(ss_base != -1);
unsigned long ss_sp = (unsigned long)ss_base + ss_size;
/* pass the shadow stack pointer to make_fcontext
/* pass the shadow stack pointer to hoost_make_fcontext
i.e., link the new shadow stack with the new fcontext
TODO should be a better way? */
*((unsigned long*)(reinterpret_cast< uintptr_t >( stack_top)- 8)) = ss_sp;
/* Todo: place shadow stack info in 64byte gap */
*((unsigned long*)(reinterpret_cast< uintptr_t >( storage)- 8)) = (unsigned long) ss_base;
*((unsigned long*)(reinterpret_cast< uintptr_t >( storage)- 16)) = ss_size;
#endif
const fcontext_t fctx = make_fcontext( stack_top, size, & fiber_entry< Record >);
const fcontext_t fctx = hoost_make_fcontext( stack_top, size, & fiber_entry< Record >);
BOOST_ASSERT( nullptr != fctx);
// transfer control structure to context-stack
return jump_fcontext( fctx, record).fctx;
return hoost_jump_fcontext( fctx, record).fctx;
}

template< typename Record, typename StackAlloc, typename Fn >
Expand Down Expand Up @@ -241,18 +241,18 @@ fcontext_t create_fiber2( preallocated palloc, StackAlloc && salloc, Fn && fn) {
void *ss_base = (void *)syscall(__NR_map_shadow_stack, 0, ss_size, SHADOW_STACK_SET_TOKEN);
BOOST_ASSERT(ss_base != -1);
unsigned long ss_sp = (unsigned long)ss_base + ss_size;
/* pass the shadow stack pointer to make_fcontext
/* pass the shadow stack pointer to hoost_make_fcontext
i.e., link the new shadow stack with the new fcontext
TODO should be a better way? */
*((unsigned long*)(reinterpret_cast< uintptr_t >( stack_top)- 8)) = ss_sp;
/* Todo: place shadow stack info in 64byte gap */
*((unsigned long*)(reinterpret_cast< uintptr_t >( storage)- 8)) = (unsigned long) ss_base;
*((unsigned long*)(reinterpret_cast< uintptr_t >( storage)- 16)) = ss_size;
#endif
const fcontext_t fctx = make_fcontext( stack_top, size, & fiber_entry< Record >);
const fcontext_t fctx = hoost_make_fcontext( stack_top, size, & fiber_entry< Record >);
BOOST_ASSERT( nullptr != fctx);
// transfer control structure to context-stack
return jump_fcontext( fctx, record).fctx;
return hoost_jump_fcontext( fctx, record).fctx;
}

}
Expand Down Expand Up @@ -302,7 +302,7 @@ class fiber {

~fiber() {
if ( BOOST_UNLIKELY( nullptr != fctx_) ) {
detail::ontop_fcontext(
detail::hoost_ontop_fcontext(
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
detail::exchange( fctx_, nullptr),
#else
Expand Down Expand Up @@ -330,7 +330,7 @@ class fiber {

fiber resume() && {
BOOST_ASSERT( nullptr != fctx_);
return { detail::jump_fcontext(
return { detail::hoost_jump_fcontext(
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
detail::exchange( fctx_, nullptr),
#else
Expand All @@ -343,7 +343,7 @@ class fiber {
fiber resume_with( Fn && fn) && {
BOOST_ASSERT( nullptr != fctx_);
auto p = std::forward< Fn >( fn);
return { detail::ontop_fcontext(
return { detail::hoost_ontop_fcontext(
#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
detail::exchange( fctx_, nullptr),
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
.file "jump_arm64_aapcs_elf_gas.S"
.text
.align 2
.global jump_fcontext
.type jump_fcontext, %function
jump_fcontext:
.global hoost_jump_fcontext
.type hoost_jump_fcontext, %function
hoost_jump_fcontext:
# prepare stack for GP + FPU
sub sp, sp, #0xb0

Expand Down Expand Up @@ -109,6 +109,6 @@ jump_fcontext:
add sp, sp, #0xb0

ret x4
.size jump_fcontext,.-jump_fcontext
.size hoost_jump_fcontext,.-hoost_jump_fcontext
# Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
*******************************************************/

.text
.globl _jump_fcontext
.globl _hoost_jump_fcontext
.balign 16
_jump_fcontext:
_hoost_jump_fcontext:
; prepare stack for GP + FPU
sub sp, sp, #0xb0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
;*******************************************************

AREA |.text|, CODE, READONLY, ALIGN=4, CODEALIGN
EXPORT jump_fcontext
EXPORT hoost_jump_fcontext

jump_fcontext proc
hoost_jump_fcontext proc
; prepare stack for GP + FPU
sub sp, sp, #0xd0

Expand Down Expand Up @@ -130,4 +130,4 @@ jump_fcontext proc

ret x4
ENDP
END
END
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

.file "jump_arm_aapcs_elf_gas.S"
.text
.globl jump_fcontext
.globl hoost_jump_fcontext
.align 2
.type jump_fcontext,%function
.type hoost_jump_fcontext,%function
.syntax unified
jump_fcontext:
hoost_jump_fcontext:
@ save LR as PC
push {lr}
@ save hidden,V1-V8,LR
Expand Down Expand Up @@ -82,7 +82,7 @@ jump_fcontext:

@ restore PC
pop {pc}
.size jump_fcontext,.-jump_fcontext
.size hoost_jump_fcontext,.-hoost_jump_fcontext

@ Mark that we don't need executable stack.
.section .note.GNU-stack,"",%progbits
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
*******************************************************/

.text
.globl _jump_fcontext
.globl _hoost_jump_fcontext
.align 2
_jump_fcontext:
_hoost_jump_fcontext:
@ save LR as PC
push {lr}
@ save hidden,V1-V8,LR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

AREA |.text|, CODE
ALIGN 4
EXPORT jump_fcontext
EXPORT hoost_jump_fcontext

jump_fcontext PROC
hoost_jump_fcontext PROC
; save LR as PC
push {lr}
; save hidden,V1-V8,LR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
.def @feat.00; .scl 3; .type 0; .endef
.set @feat.00, 1

.globl _jump_fcontext
.def _jump_fcontext; .scl 2; .type 32; .endef
_jump_fcontext:
.globl _hoost_jump_fcontext
.def _hoost_jump_fcontext; .scl 2; .type 32; .endef
_hoost_jump_fcontext:
/* prepare stack */
leal -0x2c(%esp), %esp

Expand Down Expand Up @@ -71,9 +71,9 @@ _jump_fcontext:
/* store ESP (pointing to context-data) in EAX */
movl %esp, %eax

/* firstarg of jump_fcontext() == fcontext to jump to */
/* firstarg of hoost_jump_fcontext() == fcontext to jump to */
movl 0x30(%esp), %ecx

/* restore ESP (pointing to context-data) from ECX */
movl %ecx, %esp

Expand Down Expand Up @@ -120,4 +120,4 @@ _jump_fcontext:
jmp *%ecx

.section .drectve
.ascii " -export:\"_jump_fcontext\""
.ascii " -export:\"_hoost_jump_fcontext\""
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
.def @feat.00; .scl 3; .type 0; .endef
.set @feat.00, 1

.globl _jump_fcontext
.def _jump_fcontext; .scl 2; .type 32; .endef
_jump_fcontext:
.globl _hoost_jump_fcontext
.def _hoost_jump_fcontext; .scl 2; .type 32; .endef
_hoost_jump_fcontext:
/* prepare stack */
leal -0x2c(%esp), %esp

Expand Down Expand Up @@ -71,9 +71,9 @@ _jump_fcontext:
/* store ESP (pointing to context-data) in EAX */
movl %esp, %eax

/* firstarg of jump_fcontext() == fcontext to jump to */
/* firstarg of hoost_jump_fcontext() == fcontext to jump to */
movl 0x30(%esp), %ecx

/* restore ESP (pointing to context-data) from ECX */
movl %ecx, %esp

Expand Down Expand Up @@ -120,4 +120,4 @@ _jump_fcontext:
jmp *%ecx

.section .drectve
.ascii " -export:\"jump_fcontext\""
.ascii " -export:\"hoost_jump_fcontext\""
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
.model flat, c
.code

jump_fcontext PROC BOOST_CONTEXT_EXPORT
hoost_jump_fcontext PROC BOOST_CONTEXT_EXPORT
; prepare stack
lea esp, [esp-02ch]

Expand Down Expand Up @@ -55,17 +55,17 @@ ENDIF
mov eax, [edx]
mov [esp+018h], eax

mov [esp+01ch], edi ; save EDI
mov [esp+020h], esi ; save ESI
mov [esp+024h], ebx ; save EBX
mov [esp+028h], ebp ; save EBP
mov [esp+01ch], edi ; save EDI
mov [esp+020h], esi ; save ESI
mov [esp+024h], ebx ; save EBX
mov [esp+028h], ebp ; save EBP

; store ESP (pointing to context-data) in EAX
mov eax, esp

; firstarg of jump_fcontext() == fcontext to jump to
; firstarg of hoost_jump_fcontext() == fcontext to jump to
mov ecx, [esp+030h]

; restore ESP (pointing to context-data) from ECX
mov esp, ecx

Expand Down Expand Up @@ -98,10 +98,10 @@ ENDIF

mov ecx, [esp+02ch] ; restore EIP

mov edi, [esp+01ch] ; restore EDI
mov esi, [esp+020h] ; restore ESI
mov ebx, [esp+024h] ; restore EBX
mov ebp, [esp+028h] ; restore EBP
mov edi, [esp+01ch] ; restore EDI
mov esi, [esp+020h] ; restore ESI
mov ebx, [esp+024h] ; restore EBX
mov ebp, [esp+028h] ; restore EBP

; prepare stack
lea esp, [esp+030h]
Expand All @@ -112,5 +112,5 @@ ENDIF

; jump to context
jmp ecx
jump_fcontext ENDP
hoost_jump_fcontext ENDP
END
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

.file "jump_i386_sysv_elf_gas.S"
.text
.globl jump_fcontext
.globl hoost_jump_fcontext
.align 2
.type jump_fcontext,@function
jump_fcontext:
.type hoost_jump_fcontext,@function
hoost_jump_fcontext:
leal -0x1c(%esp), %esp /* prepare stack */

#if !defined(BOOST_USE_TSX)
Expand All @@ -54,10 +54,10 @@ jump_fcontext:
/* store ESP (pointing to context-data) in ECX */
movl %esp, %ecx

/* first arg of jump_fcontext() == fcontext to jump to */
/* first arg of hoost_jump_fcontext() == fcontext to jump to */
movl 0x24(%esp), %eax

/* second arg of jump_fcontext() == data to be transferred */
/* second arg of hoost_jump_fcontext() == data to be transferred */
movl 0x28(%esp), %edx

/* restore ESP (pointing to context-data) from EAX */
Expand Down Expand Up @@ -91,7 +91,7 @@ jump_fcontext:

/* jump to context */
jmp *%ecx
.size jump_fcontext,.-jump_fcontext
.size hoost_jump_fcontext,.-hoost_jump_fcontext

/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits
Expand Down
Loading

0 comments on commit d554ed8

Please sign in to comment.