Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat: add windows compat interface #21

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: v1-winbuild-{build}

image: Visual Studio 2019

platform:
- Win32
- x64

environment:
vspath: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community'

configuration:
- Release

skip_commits:
message: /workflows/
files:
- '.github/**'

before_build:
- if %PLATFORM%==Win32 call "%vspath%\VC\Auxiliary\Build\vcvars32.bat"
- if %PLATFORM%==x64 call "%vspatH%\VC\Auxiliary\Build\vcvars64.bat"

build_script:
- .\scripts\win_build.bat
- ctest -C Debug --test-dir .\tests\
35 changes: 35 additions & 0 deletions include/ctraces/ctr_compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* CTraces
* =======
* Copyright 2022 Eduardo Silva <[email protected]>
*
* 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 CTR_COMPAT_H
#define CTR_COMPAT_H

#ifdef _WIN32

#ifndef ssize_t
typedef SSIZE_T ssize_t;
#endif


#else
#include <unistd.h>

#endif /* !_WIN32 */

#endif /* !CTR_COMPAT_H */
2 changes: 2 additions & 0 deletions include/ctraces/ctr_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef CTR_RANDOM_H
#define CTR_RANDOM_H

#include <ctraces/ctraces.h>

ssize_t ctr_random_get(void *buf, size_t len);

#endif
5 changes: 5 additions & 0 deletions include/ctraces/ctraces.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#define CTR_FALSE 0
#define CTR_TRUE !CTR_FALSE

#include <ctraces/ctr_info.h>
#include <ctraces/ctr_compat.h>

/* local libs */
#include <cfl/cfl.h>
#include <mpack/mpack.h>
Expand All @@ -35,6 +38,8 @@

/* options is unused for now */
struct ctrace_opts {
/* windows compiler: error C2016: C requires that a struct or union have at least one member */
int _make_windows_happy;
};

struct ctrace {
Expand Down
1 change: 1 addition & 0 deletions scripts/win_build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
setlocal
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
path "C:\Program Files (x86)\MSBuild\16.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin";%path%
git submodule update --init --recursive
cd build
cmake -G "NMake Makefiles" -DCTR_TESTS=On ..\
cmake --build .
Expand Down