Skip to content

Commit

Permalink
add new code layout for list_cpu_features
Browse files Browse the repository at this point in the history
test
  • Loading branch information
toor1245 committed Nov 19, 2021
1 parent fc52c64 commit 02711c1
Show file tree
Hide file tree
Showing 10 changed files with 575 additions and 388 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ add_library(CpuFeature::cpu_features ALIAS cpu_features)
# program : list_cpu_features
#

add_executable(list_cpu_features ${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features.c)
file(GLOB LIST_CPU_FEATURES_SRCS CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features_*.c")
add_executable(list_cpu_features ${PROJECT_SOURCE_DIR}/src/utils/list_cpu_features.c
${LIST_CPU_FEATURES_SRCS})
target_link_libraries(list_cpu_features PRIVATE cpu_features)
add_executable(CpuFeature::list_cpu_features ALIAS list_cpu_features)

Expand Down
33 changes: 33 additions & 0 deletions src/utils/bump_allocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2017 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef CPU_FEATURES_BUMP_ALLOCATOR_H_
#define CPU_FEATURES_BUMP_ALLOCATOR_H_

#include <stddef.h>

#define ALIGN 8

// We use a bump allocator to allocate strings and nodes of the tree,
// Memory is not intended to be reclaimed.
typedef struct {
char* ptr;
size_t size;
} BumpAllocator;

void assertAligned();
void BA_Align();
void* BA_Bump(size_t size);

#endif // CPU_FEATURES_BUMP_ALLOCATOR_H_
Loading

0 comments on commit 02711c1

Please sign in to comment.