Skip to content

Commit

Permalink
nits: clang-format-17 checks passing
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Mar 4, 2024
1 parent e3f5a14 commit 0e6fc63
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ DerivePointerAlignment: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
SplitEmptyFunction: false
SplitEmptyRecord: false
---
18 changes: 12 additions & 6 deletions func/cpp/py_func.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extern "C" {
extern "C"
{
#include "pyinit.h"
}

Expand All @@ -20,7 +21,8 @@ extern "C" {
* Returns the relevant Python entry function. We need to invoke different
* functions depending on which Faasm function index we're dealing with.
*/
const char* getPythonFunctionName() {
const char* getPythonFunctionName()
{
char* entryFunc = faasmGetPythonEntry();

if (strlen(entryFunc) == 0) {
Expand All @@ -34,7 +36,8 @@ const char* getPythonFunctionName() {
* Returns the working dir we need to be in to import the Python module
* for the required function.
*/
const char* getPythonWorkingDir(const char* user, const char* funcName) {
const char* getPythonWorkingDir(const char* user, const char* funcName)
{
auto workingDir = new char[60];

#ifdef __wasm__
Expand All @@ -50,7 +53,8 @@ const char* getPythonWorkingDir(const char* user, const char* funcName) {
* Returns the name of the python module to execute. If executing in wasm this
* will be different to when executing natively.
*/
const char* getPythonModuleName(const char* funcName) {
const char* getPythonModuleName(const char* funcName)
{
#ifdef __wasm__
return "function";
#else
Expand All @@ -61,7 +65,8 @@ const char* getPythonModuleName(const char* funcName) {
/**
* Initialise CPython using a Faasm zygote to avoid doing so repeatedly
*/
FAASM_ZYGOTE() {
FAASM_ZYGOTE()
{
Py_InitializeEx(0);

// 21/12/2022 - Numpy support is broken
Expand Down Expand Up @@ -90,7 +95,8 @@ FAASM_ZYGOTE() {
return 0;
}

int main(int argc, char* argv[]) {
int main(int argc, char* argv[])
{
// With this line uncommented, this file can be run as a normal executable
// for testing setEmulatedMessageFromJson(R"({"user": "python", "function":
// "py_func", "py_user": "python", "py_func": "lang_test", "py_entry":
Expand Down
3 changes: 2 additions & 1 deletion func/cpp/pyinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
fprintf(devNull, "%p", trunc##sfx); \
fprintf(devNull, "%p", rint##sfx);

void setUpPyNumpy() {
void setUpPyNumpy()
{
FILE* devNull = fopen("/dev/null", "w");

// Maths
Expand Down
5 changes: 3 additions & 2 deletions func/cpp/pyinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#define FAASM_PYTHON_H

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

void setUpPyNumpy();
void setUpPyNumpy();

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions tasks/format_code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from faasmtools.env import LLVM_VERSION
from faasmtools.env import LLVM_NATIVE_VERSION
from invoke import task
from tasks.env import PROJ_ROOT
from subprocess import run
Expand Down Expand Up @@ -52,7 +52,7 @@ def format(ctx, check=False):
)

clang_cmd = [
"clang-format-{}".format(LLVM_VERSION.split(".")[0]),
"clang-format-{}".format(LLVM_NATIVE_VERSION.split(".")[0]),
"--dry-run --Werror" if check else "-i",
"-style=file",
" ".join(files_to_check),
Expand Down

0 comments on commit 0e6fc63

Please sign in to comment.