< prev index next >
src/java.desktop/share/native/liblcms/cmsplugin.c
Print this page
@@ -28,11 +28,11 @@
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2017 Marti Maria Saguer
+// Copyright (c) 1998-2020 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -60,11 +60,11 @@
// Encoding & Decoding support functions
// ----------------------------------------------------------------------------------
// Little-Endian to Big-Endian
-// Adjust a word value after being readed/ before being written from/to an ICC profile
+// Adjust a word value after being read/ before being written from/to an ICC profile
cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word)
{
#ifndef CMS_USE_BIG_ENDIAN
cmsUInt8Number* pByte = (cmsUInt8Number*) &Word;
@@ -126,12 +126,12 @@
#else
_cmsAssert(Result != NULL);
# ifdef CMS_DONT_USE_INT64
- (*Result)[0] = QWord[0];
- (*Result)[1] = QWord[1];
+ (*Result)[0] = (*QWord)[0];
+ (*Result)[1] = (*QWord)[1];
# else
*Result = *QWord;
# endif
#endif
}
@@ -214,10 +214,12 @@
#if defined(_MSC_VER) && _MSC_VER < 1800
return TRUE;
#elif defined (__BORLANDC__)
return TRUE;
+ #elif !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L)
+ return TRUE;
#else
// fpclassify() required by C99 (only provided by MSVC >= 1800, VS2013 onwards)
return ((fpclassify(*n) == FP_ZERO) || (fpclassify(*n) == FP_NORMAL));
#endif
@@ -700,19 +702,25 @@
// On 0, use global settings
if (id == NULL)
return &globalContext;
// Search
+ _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
+
for (ctx = _cmsContextPoolHead;
ctx != NULL;
ctx = ctx ->Next) {
// Found it?
if (id == ctx)
- return ctx; // New-style context,
+ {
+ _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
+ return ctx; // New-style context
+ }
}
+ _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
return &globalContext;
}
// Internal: get the memory area associanted with each context client
@@ -797,10 +805,11 @@
struct _cmsContext_struct* ctx;
struct _cmsContext_struct fakeContext;
// See the comments regarding locking in lcms2_internal.h
// for an explanation of why we need the following code.
+#ifndef CMS_NO_PTHREADS
#ifdef CMS_IS_WINDOWS_
#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
{
static HANDLE _cmsWindowsInitMutex = NULL;
static volatile HANDLE* mutex = &_cmsWindowsInitMutex;
@@ -818,10 +827,11 @@
if (*mutex == NULL || !ReleaseMutex(*mutex))
return NULL;
}
#endif
#endif
+#endif
_cmsInstallAllocFunctions(_cmsFindMemoryPlugin(Plugin), &fakeContext.DefaultMemoryManager);
fakeContext.chunks[UserPtr] = UserData;
fakeContext.chunks[MemPlugin] = &fakeContext.DefaultMemoryManager;
@@ -941,29 +951,10 @@
return (cmsContext) ctx;
}
-/*
-static
-struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
-{
- struct _cmsContext_struct* prev;
-
- // Search for previous
- for (prev = _cmsContextPoolHead;
- prev != NULL;
- prev = prev ->Next)
- {
- if (prev ->Next == id)
- return prev;
- }
-
- return NULL; // List is empty or only one element!
-}
-*/
-
// Frees any resources associated with the given context,
// and destroys the context placeholder.
// The ContextID can no longer be used in any THR operation.
void CMSEXPORT cmsDeleteContext(cmsContext ContextID)
{
< prev index next >