Skip to content
Draft
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
210 changes: 210 additions & 0 deletions ports/babl/msvc-restrict-compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
diff --git a/babl/babl-extension.c b/babl/babl-extension.c
index 772cf60..45013a4 100644
--- a/babl/babl-extension.c
+++ b/babl/babl-extension.c
@@ -290,7 +290,8 @@ dir_foreach (const char *base_path,
path = babl_strcat (path, entry);

if ((extension = strrchr (entry, '.')) != NULL &&
- !strcmp (extension, SHREXT))
+ !strcmp (extension, SHREXT) &&
+ strncmp (entry, BABL_LIBRARY, strlen (BABL_LIBRARY)))
{
int excluded = 0;
for (int i = 0; ctx->exclusion_patterns[i]; i++)
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 5c03ea9..f436c9a 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -127,8 +127,13 @@ babl_gc (void)
}
}

-#define BABL_LIKELY(x) __builtin_expect(!!(x), 1)
-#define BABL_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#ifdef _MSC_VER
+ #define BABL_LIKELY(x) (x)
+ #define BABL_UNLIKELY(x) (x)
+#else
+ #define BABL_LIKELY(x) __builtin_expect(!!(x), 1)
+ #define BABL_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#endif

static float timings[256] = {0,};

diff --git a/babl/babl-format.c b/babl/babl-format.c
index df44b1f..f6d399e 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -21,7 +21,7 @@
#include <stdarg.h>
#include <math.h>

-#ifdef _WIN64
+#ifdef _WIN32
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
@@ -276,9 +276,9 @@ babl_format_n (const Babl *btype,
int id = 0;
int planar = 0;
BablModel *model = (BablModel *)babl_model ("Y");
- BablComponent *component [components];
- BablSampling *sampling [components];
- const BablType *type [components];
+ BablComponent **component = babl_malloc (sizeof (BablComponent *) * components);
+ BablSampling **sampling = babl_malloc (sizeof (BablSampling *) * components);
+ const BablType **type = babl_malloc (sizeof (const BablType *) * components);
char *name = NULL;

for (i = 0; i<components; i++)
@@ -296,6 +296,9 @@ babl_format_n (const Babl *btype,
* returning the preexistent one instead.
*/
babl_free (name);
+ babl_free (component);
+ babl_free (sampling);
+ babl_free ((void *) type);
return babl;
}

@@ -305,6 +308,9 @@ babl_format_n (const Babl *btype,
babl_space("sRGB"),
component, sampling, type, NULL);

+ babl_free (component);
+ babl_free (sampling);
+ babl_free ((void *) type);
babl_format_set_is_format_n (babl);

babl_db_insert (db, babl);
diff --git a/babl/babl-image.c b/babl/babl-image.c
index 44c0cac..9e4a1b5 100644
--- a/babl/babl-image.c
+++ b/babl/babl-image.c
@@ -107,10 +107,11 @@ babl_image_from_linear (char *buffer,
case BABL_FORMAT:
components = format->format.components;

-#if 1
+#if defined(__GNUC__) || defined(__clang__)
babl = __atomic_exchange_n (&format->format.image_template, NULL,
__ATOMIC_ACQ_REL);
#else
+ /* MSVC lacks the GCC atomic builtin used here; keep the fallback path. */
/* todo: add a configure check for the above gcc extension and use
a mutex if we do not have it?
*/
diff --git a/babl/base/babl-rgb-converter.c b/babl/base/babl-rgb-converter.c
index 52f912d..3d89a2b 100644
--- a/babl/base/babl-rgb-converter.c
+++ b/babl/base/babl-rgb-converter.c
@@ -201,7 +201,7 @@ universal_nonlinear_rgb_u8_converter (const Babl *conversion,
uint8_t *rgb_in_u8 = (void*)src_char;
uint8_t *rgb_out_u8 = (void*)dst_char;

- float rgba_out[4*samples];
+ float *rgba_out = babl_malloc (sizeof (float) * 4 * samples);

for (i = 0; i < samples; i++)
{
@@ -221,6 +221,8 @@ universal_nonlinear_rgb_u8_converter (const Babl *conversion,
rgb_out_u8[i*3+c] = rgba_out[i*4+c] * 255.0f;
}

+ babl_free (rgba_out);
+
}


diff --git a/extensions/gegl-fixups.c b/extensions/gegl-fixups.c
index e8fd785..ca3bbc1 100644
--- a/extensions/gegl-fixups.c
+++ b/extensions/gegl-fixups.c
@@ -49,6 +49,12 @@
#include "base/util.h"
#include "extensions/util.h"

+#if defined(_MSC_VER) && !defined(__clang__)
+#define BABL_ATTRIBUTE_UNUSED
+#else
+#define BABL_ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
+

/* lookup tables used in conversion */

@@ -184,7 +190,7 @@ conv_F_8g (const Babl *conversion,
}


-static inline void __attribute__((unused))
+static inline void BABL_ATTRIBUTE_UNUSED
conv_8_F (const Babl *conversion,
unsigned char *src,
unsigned char *dst,
@@ -233,7 +239,7 @@ conv_rgbaF_rgb8 (const Babl *conversion,
}


-static void __attribute__((unused))
+static void BABL_ATTRIBUTE_UNUSED
conv_rgbaF_rgba8 (const Babl *conversion,
unsigned char *src,
unsigned char *dst,
@@ -267,7 +273,7 @@ conv_rgbaF_rgba8 (const Babl *conversion,

#define conv_rgbaF_rgbP8 conv_rgbaF_rgba8

-static void __attribute__((unused))
+static void BABL_ATTRIBUTE_UNUSED
conv_rgbF_rgb8 (const Babl *conversion,
unsigned char *src,
unsigned char *dst,
@@ -276,7 +282,7 @@ conv_rgbF_rgb8 (const Babl *conversion,
conv_F_8g (conversion, src, dst, samples * 3);
}

-static void __attribute__((unused))
+static void BABL_ATTRIBUTE_UNUSED
conv_gaF_ga8 (const Babl *conversion,
unsigned char *src,
unsigned char *dst,
diff --git a/meson.build b/meson.build
index a1b46c0..8d6d7b4 100644
--- a/meson.build
+++ b/meson.build
@@ -209,6 +209,12 @@ endif
if cc.get_argument_syntax() == 'msvc'
#Needed otherwise MSVC get angry with the headers provided by UCRT
common_c_flags += ['/D_USE_MATH_DEFINES']
endif
+
+if cc.get_id() == 'msvc'
+ common_c_flags += ['/std:c11']
+ common_c_flags += ['/experimental:c11atomics']
+ common_c_flags += ['/D__restrict__=__restrict']
+endif

add_project_arguments(common_c_flags, language: 'c')
diff --git a/babl/babl.c b/babl/babl.c
--- a/babl/babl.c
+++ b/babl/babl.c
@@ -101,7 +101,7 @@ babl_dir_list (void)
babl_fatal ("Converting module filename to UTF-8 failed");

/* If the DLL file name is of the format
- * <foobar>\bin\*.dll, use <foobar>\lib\{BABL_LIBRARY}.
+ * <foobar>\bin\*.dll, use <foobar>\plugins\{BABL_LIBRARY}.
* Otherwise, use the directory where the DLL is.
*/

@@ -119,7 +119,7 @@ babl_dir_list (void)
strlen (BABL_DIR_SEPARATOR BABL_LIBRARY) + 4));
strcpy_s (filename_tmp, strlen(filename) + 1, filename);
babl_free (filename);
- strcat (filename_tmp, "lib" BABL_DIR_SEPARATOR BABL_LIBRARY);
+ strcat (filename_tmp, "plugins" BABL_DIR_SEPARATOR BABL_LIBRARY);
filename = filename_tmp;
}
}
14 changes: 14 additions & 0 deletions ports/babl/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vcpkg_extract_source_archive(
SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
msvc-restrict-compat.patch
remove-consistency-check.patch
)

Expand Down Expand Up @@ -37,9 +38,22 @@ vcpkg_configure_meson(
"g-ir-scanner='${GIR_SCANNER}'"
)
vcpkg_install_meson()

if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/babl-${VERSION_MAJOR_MINOR}")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/plugins")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/babl-${VERSION_MAJOR_MINOR}" "${CURRENT_PACKAGES_DIR}/plugins/babl-${VERSION_MAJOR_MINOR}")
endif()

if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/babl-${VERSION_MAJOR_MINOR}")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/plugins")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/babl-${VERSION_MAJOR_MINOR}" "${CURRENT_PACKAGES_DIR}/debug/plugins/babl-${VERSION_MAJOR_MINOR}")
endif()

vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

vcpkg_copy_tools(TOOL_NAMES babl AUTO_CLEAN)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
3 changes: 2 additions & 1 deletion ports/babl/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "babl",
"version": "0.1.124",
"port-version": 1,
"description": "A pixel encoding and color space conversion engine.",
"homepage": "https://gegl.org/babl/",
"license": "LGPL-3.0-or-later",
"supports": "!windows | mingw",
"dependencies": [
{
"name": "vcpkg-tool-meson",
Expand All @@ -20,6 +20,7 @@
},
"introspection": {
"description": "Enable introspection",
"supports": "!windows | mingw",
"dependencies": [
"gobject-introspection"
]
Expand Down
5 changes: 5 additions & 0 deletions versions/b-/babl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "b14b22d34c83cc0a3adda95630a98b5cda2e4e71",
"version": "0.1.124",
"port-version": 1
},
{
"git-tree": "712240fb456214b23808542557986b3787dcc174",
"version": "0.1.124",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
},
"babl": {
"baseline": "0.1.124",
"port-version": 0
"port-version": 1
},
"backward-cpp": {
"baseline": "2023-11-24",
Expand Down