Initial libenergytrace stubs

This commit is contained in:
Ariel Abreu 2020-07-05 13:32:09 -04:00
commit e277fcfd43
No known key found for this signature in database
GPG Key ID: F4D43CC7053EA2B3
3 changed files with 140 additions and 0 deletions

12
CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
project(energytrace)
set(DYLIB_INSTALL_NAME "/usr/lib/libenergytrace.dylib")
set(DYLIB_COMPAT_VERSION "1.0.0")
set(DYLIB_CURRENT_VERSION "1.0.0")
add_darling_library(energytrace SHARED
src/energytrace.c
)
make_fat(energytrace)
target_link_libraries(energytrace system)
install(TARGETS energytrace DESTINATION libexec/darling/usr/lib)

61
include/energytrace.h Normal file
View File

@ -0,0 +1,61 @@
/*
This file is part of Darling.
Copyright (C) 2020 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _energytrace_H_
#define _energytrace_H_
#include <stdint.h>
// generated signatures
void* entr_act_associate(void);
void* entr_act_set(void);
void* entr_act_setd(void);
void* entr_event(void);
void* entr_shouldtrace(void);
// fixed up signatures
void entr_act_begin(int comp, int act, int assertion_id, int intensity, int val);
void entr_act_end(int comp, int act, int assertion_id, int intensity, int val);
void entr_act_modify(int comp, int act, int assertion_id, int mod, int val);
// guessed constants
enum {
kEnTrQualNone,
kEnTrQualSPKeepSystemAwake,
};
enum {
kEnTrCompSysPower,
};
enum {
kEnTrValNone,
};
enum {
kEnTrActSPPMAssertion,
};
enum {
kEnTrModSPRetain,
kEnTrModSPRelease,
};
#endif

67
src/energytrace.c Normal file
View File

@ -0,0 +1,67 @@
/*
This file is part of Darling.
Copyright (C) 2020 Lubos Dolezel
Darling is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Darling is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Darling. If not, see <http://www.gnu.org/licenses/>.
*/
#include <energytrace.h>
#include <stdlib.h>
#include <stdio.h>
static int verbose = 0;
__attribute__((constructor))
static void initme(void) {
verbose = getenv("STUB_VERBOSE") != NULL;
}
void* entr_act_associate(void) {
if (verbose) puts("STUB: entr_act_associate called");
return NULL;
}
void entr_act_begin(int comp, int act, int assertion_id, int intensity, int val) {
if (verbose) puts("STUB: entr_act_begin called");
};
void entr_act_end(int comp, int act, int assertion_id, int intensity, int val) {
if (verbose) puts("STUB: entr_act_end called");
};
void entr_act_modify(int comp, int act, int assertion_id, int mod, int val) {
if (verbose) puts("STUB: entr_act_modify called");
};
void* entr_act_set(void) {
if (verbose) puts("STUB: entr_act_set called");
return NULL;
}
void* entr_act_setd(void) {
if (verbose) puts("STUB: entr_act_setd called");
return NULL;
}
void* entr_event(void) {
if (verbose) puts("STUB: entr_event called");
return NULL;
}
void* entr_shouldtrace(void) {
if (verbose) puts("STUB: entr_shouldtrace called");
return NULL;
}