mirror of
https://git.planet-casio.com/Lephenixnoir/libprof.git
synced 2025-05-09 19:39:24 +02:00
Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
|
6df36ce8d3 | ||
|
5b669e5529 | ||
|
6d82009532 | ||
|
b6657c0834 | ||
|
ac348bce34 | ||
|
c0d5b053d9 | ||
|
fd90842b82 | ||
|
08ee98cef1 | ||
|
a9f1dc3ec8 |
5 changed files with 36 additions and 16 deletions
|
@ -1,8 +1,8 @@
|
|||
# Build system for the libprof library for gint
|
||||
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(libprof VERSION 2.2.1 LANGUAGES C)
|
||||
find_package(Gint 2.2.1 REQUIRED)
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(libprof VERSION 2.4.0 LANGUAGES C)
|
||||
find_package(Gint 2.4.0 REQUIRED)
|
||||
|
||||
configure_file(libprof.h libprof.h)
|
||||
|
||||
|
@ -14,8 +14,8 @@ target_include_directories(${NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
|||
target_link_libraries(${NAME} Gint::Gint)
|
||||
|
||||
install(TARGETS ${NAME}
|
||||
DESTINATION "${FXSDK_COMPILER_INSTALL}")
|
||||
DESTINATION "${FXSDK_LIB}")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libprof.h"
|
||||
DESTINATION "${FXSDK_COMPILER_INSTALL}/include")
|
||||
DESTINATION "${FXSDK_INCLUDE}")
|
||||
install(FILES cmake/FindLibProf.cmake
|
||||
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
include(FindSimpleLibrary)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_simple_library("libprof-${FXSDK_PLATFORM}.a" include/libprof.h
|
||||
find_package(Gint 2.2.1 REQUIRED)
|
||||
|
||||
find_simple_library("libprof-${FXSDK_PLATFORM}.a" libprof.h
|
||||
"PROF_VERSION" PATH_VAR PROF_PATH VERSION_VAR PROF_VERSION)
|
||||
|
||||
find_package_handle_standard_args(LibProf
|
||||
|
@ -12,5 +14,6 @@ if(LibProf_FOUND)
|
|||
add_library(LibProf::LibProf UNKNOWN IMPORTED)
|
||||
set_target_properties(LibProf::LibProf PROPERTIES
|
||||
IMPORTED_LOCATION "${PROF_PATH}"
|
||||
INTERFACE_LINK_OPTIONS -lprof-${FXSDK_PLATFORM})
|
||||
INTERFACE_LINK_OPTIONS -lprof-${FXSDK_PLATFORM}
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES Gint::Gint)
|
||||
endif()
|
||||
|
|
|
@ -15,10 +15,10 @@ install:
|
|||
@ fxsdk build-cg install
|
||||
|
||||
uninstall:
|
||||
@ if [[ -e build-fx/install_manifest.txt ]]; then \
|
||||
@ if [ -e build-fx/install_manifest.txt ]; then \
|
||||
xargs rm -f < build-fx/install_manifest.txt; \
|
||||
fi
|
||||
@ if [[ -e build-cg/install_manifest.txt ]]; then \
|
||||
@ if [ -e build-cg/install_manifest.txt ]; then \
|
||||
xargs rm -f < build-cg/install_manifest.txt; \
|
||||
fi
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ int prof_init(void)
|
|||
int timer = -1;
|
||||
for(int t = 2; t >= 0 && timer == -1; t--)
|
||||
{
|
||||
timer = timer_setup(t | TIMER_Pphi_4, 0xffffffff, callback);
|
||||
timer = timer_configure(t | TIMER_Pphi_4, 0xffffffff,
|
||||
GINT_CALL(callback));
|
||||
}
|
||||
if(timer == -1)
|
||||
{
|
||||
|
|
28
libprof.h
28
libprof.h
|
@ -5,6 +5,10 @@
|
|||
#ifndef LIBPROF_LIBPROF
|
||||
#define LIBPROF_LIBPROF
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gint/defs/attributes.h>
|
||||
|
||||
|
@ -54,7 +58,7 @@ extern uint32_t volatile *prof_tcnt;
|
|||
function was already executing then the deepest instance in the stack is
|
||||
used instead of creating a new counter. */
|
||||
#define prof_enter(prof) { \
|
||||
if(!prof.rec++) prof.elapsed += *prof_tcnt; \
|
||||
if(!(prof).rec++) (prof).elapsed += *prof_tcnt; \
|
||||
}
|
||||
|
||||
/* prof_leave(): Stop counting time for a function
|
||||
|
@ -63,7 +67,15 @@ extern uint32_t volatile *prof_tcnt;
|
|||
are not as exactly as many prof_leave()'s as prof_enter()'s then the
|
||||
resulting time measure will not be relevant at all. */
|
||||
#define prof_leave(prof) { \
|
||||
if(!--prof.rec) prof.elapsed -= *prof_tcnt; \
|
||||
if(!--(prof).rec) (prof).elapsed -= *prof_tcnt; \
|
||||
}
|
||||
|
||||
/* Variant of prof_enter()/prof_leave() for non-recursive contexts */
|
||||
#define prof_enter_norec(prof) { \
|
||||
(prof).elapsed += *prof_tcnt; \
|
||||
}
|
||||
#define prof_leave_norec(prof) { \
|
||||
(prof).elapsed -= *prof_tcnt; \
|
||||
}
|
||||
|
||||
/* prof_exec(): Measure a single block of code
|
||||
|
@ -75,11 +87,11 @@ extern uint32_t volatile *prof_tcnt;
|
|||
exec_code();
|
||||
}); */
|
||||
#define prof_exec(code) ({ \
|
||||
prof_t prof = prof_make(); \
|
||||
prof_enter(prof); \
|
||||
prof_t _prof = prof_make(); \
|
||||
prof_enter(_prof); \
|
||||
code; \
|
||||
prof_leave(prof); \
|
||||
prof_time(prof); \
|
||||
prof_leave(_prof); \
|
||||
prof_time(_prof); \
|
||||
})
|
||||
|
||||
//---
|
||||
|
@ -90,4 +102,8 @@ extern uint32_t volatile *prof_tcnt;
|
|||
Should only be called when the context is not currently executing. */
|
||||
uint32_t prof_time(prof_t prof);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBPROF_LIBPROF */
|
||||
|
|
Loading…
Add table
Reference in a new issue