Surface Book 2 (15-inch): <b>Microsoft</b> supersizes its most powerful portable PC

Don't call it Surface Pro 5. The latest iteration of the Surface Pro loses the model number, keeps the kickstand, and adds mostly subtle refinements. Read More For the past five days, I've been using a Surface Book 2 in place of my everyday PC, a first ...

<b>Microsoft</b> Surface Book 2 (15-inch) review:

Microsoft Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 512 GB SSD - English - North America fux00001 $2,899.00 Microsoft Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 256 GB SSD - English - North America hnr00001 $2,499.00 Microsoft Surface Book ...

12 Reasons <b>Microsoft</b>'s Edge Browser Rocks (No, Really)

At just two years old, Edge is the new kid on the web browser block, but what it lacks in maturity, it makes up for in speed and convenience. Development has been swift. With each major Windows 10 release, Edge improves. Windows 10 Fall Creators Update ...

REVIEW: <b>Microsoft</b>'s newest laptop is my new favorite computer (MSFT)

It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used. I now have a new favorite computer, and it's the successor to my ...

REVIEW: <b>Microsoft</b>'s newest laptop is a powerful alternative to any of Apple's MacBooks or iPads

<b>Microsoft</b>'s original Surface Book was my favorite computer. It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used.

{'repo_name': 'Azure/azure-rest-api-specs', 'stars': '756', 'repo_language': 'TypeScript', 'file_name': 'virtualNetwork.json', 'mime_type': 'text/plain', 'hash': -5915479163804107755, 'source_dataset': 'data'}


/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * 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.
 */

// Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.

/*
 * rs_convert.rsh: Conversion Functions
 *
 * The functions below convert from a numerical vector type to another, of from one color
 * representation to another.
 */

#ifndef RENDERSCRIPT_RS_CONVERT_RSH
#define RENDERSCRIPT_RS_CONVERT_RSH

/*
 * convert: Convert numerical vectors
 *
 * Converts a vector from one numerical type to another.  The conversion are done entry per entry.
 *
 * E.g calling a = convert_short3(b); is equivalent to doing
 * a.x = (short)b.x; a.y = (short)b.y; a.z = (short)b.z;.
 *
 * Converting floating point values to integer types truncates.
 *
 * Converting numbers too large to fit the destination type yields undefined results.
 * For example, converting a float that contains 1.0e18 to a short is undefined.
 * Use clamp() to avoid this.
 */
extern float2 __attribute__((const, overloadable))
    convert_float2(float2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(float3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(float4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(char2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(char3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(char4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(uchar2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(uchar3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(uchar4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(short2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(short3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(short4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(ushort2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(ushort3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(ushort4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(int2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(int3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(int4 v);

extern float2 __attribute__((const, overloadable))
    convert_float2(uint2 v);

extern float3 __attribute__((const, overloadable))
    convert_float3(uint3 v);

extern float4 __attribute__((const, overloadable))
    convert_float4(uint4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(float2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(float3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(float4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(char2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(char3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(char4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(uchar2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(uchar3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(uchar4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(short2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(short3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(short4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(ushort2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(ushort3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(ushort4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(int2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(int3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(int4 v);

extern char2 __attribute__((const, overloadable))
    convert_char2(uint2 v);

extern char3 __attribute__((const, overloadable))
    convert_char3(uint3 v);

extern char4 __attribute__((const, overloadable))
    convert_char4(uint4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(float2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(float3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(float4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(char2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(char3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(char4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(uchar2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(uchar3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(uchar4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(short2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(short3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(short4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(ushort2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(ushort3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(ushort4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(int2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(int3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(int4 v);

extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(uint2 v);

extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(uint3 v);

extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(uint4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(float2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(float3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(float4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(char2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(char3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(char4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(uchar2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(uchar3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(uchar4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(short2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(short3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(short4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(ushort2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(ushort3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(ushort4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(int2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(int3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(int4 v);

extern short2 __attribute__((const, overloadable))
    convert_short2(uint2 v);

extern short3 __attribute__((const, overloadable))
    convert_short3(uint3 v);

extern short4 __attribute__((const, overloadable))
    convert_short4(uint4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(float2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(float3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(float4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(char2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(char3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(char4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(uchar2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(uchar3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(uchar4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(short2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(short3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(short4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(ushort2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(ushort3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(ushort4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(int2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(int3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(int4 v);

extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(uint2 v);

extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(uint3 v);

extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(uint4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(float2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(float3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(float4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(char2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(char3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(char4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(uchar2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(uchar3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(uchar4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(short2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(short3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(short4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(ushort2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(ushort3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(ushort4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(int2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(int3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(int4 v);

extern int2 __attribute__((const, overloadable))
    convert_int2(uint2 v);

extern int3 __attribute__((const, overloadable))
    convert_int3(uint3 v);

extern int4 __attribute__((const, overloadable))
    convert_int4(uint4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(float2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(float3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(float4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(char2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(char3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(char4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(uchar2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(uchar3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(uchar4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(short2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(short3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(short4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(ushort2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(ushort3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(ushort4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(int2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(int3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(int4 v);

extern uint2 __attribute__((const, overloadable))
    convert_uint2(uint2 v);

extern uint3 __attribute__((const, overloadable))
    convert_uint3(uint3 v);

extern uint4 __attribute__((const, overloadable))
    convert_uint4(uint4 v);

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float2 __attribute__((const, overloadable))
    convert_float2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float3 __attribute__((const, overloadable))
    convert_float3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float4 __attribute__((const, overloadable))
    convert_float4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float2 __attribute__((const, overloadable))
    convert_float2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float3 __attribute__((const, overloadable))
    convert_float3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float4 __attribute__((const, overloadable))
    convert_float4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float2 __attribute__((const, overloadable))
    convert_float2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float3 __attribute__((const, overloadable))
    convert_float3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern float4 __attribute__((const, overloadable))
    convert_float4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char2 __attribute__((const, overloadable))
    convert_char2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char3 __attribute__((const, overloadable))
    convert_char3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char4 __attribute__((const, overloadable))
    convert_char4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char2 __attribute__((const, overloadable))
    convert_char2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char3 __attribute__((const, overloadable))
    convert_char3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char4 __attribute__((const, overloadable))
    convert_char4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char2 __attribute__((const, overloadable))
    convert_char2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char3 __attribute__((const, overloadable))
    convert_char3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern char4 __attribute__((const, overloadable))
    convert_char4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar2 __attribute__((const, overloadable))
    convert_uchar2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar3 __attribute__((const, overloadable))
    convert_uchar3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uchar4 __attribute__((const, overloadable))
    convert_uchar4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short2 __attribute__((const, overloadable))
    convert_short2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short3 __attribute__((const, overloadable))
    convert_short3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short4 __attribute__((const, overloadable))
    convert_short4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short2 __attribute__((const, overloadable))
    convert_short2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short3 __attribute__((const, overloadable))
    convert_short3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short4 __attribute__((const, overloadable))
    convert_short4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short2 __attribute__((const, overloadable))
    convert_short2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short3 __attribute__((const, overloadable))
    convert_short3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern short4 __attribute__((const, overloadable))
    convert_short4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort2 __attribute__((const, overloadable))
    convert_ushort2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort3 __attribute__((const, overloadable))
    convert_ushort3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ushort4 __attribute__((const, overloadable))
    convert_ushort4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int2 __attribute__((const, overloadable))
    convert_int2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int3 __attribute__((const, overloadable))
    convert_int3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int4 __attribute__((const, overloadable))
    convert_int4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int2 __attribute__((const, overloadable))
    convert_int2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int3 __attribute__((const, overloadable))
    convert_int3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int4 __attribute__((const, overloadable))
    convert_int4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int2 __attribute__((const, overloadable))
    convert_int2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int3 __attribute__((const, overloadable))
    convert_int3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern int4 __attribute__((const, overloadable))
    convert_int4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint2 __attribute__((const, overloadable))
    convert_uint2(double2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint3 __attribute__((const, overloadable))
    convert_uint3(double3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint4 __attribute__((const, overloadable))
    convert_uint4(double4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint2 __attribute__((const, overloadable))
    convert_uint2(long2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint3 __attribute__((const, overloadable))
    convert_uint3(long3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint4 __attribute__((const, overloadable))
    convert_uint4(long4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint2 __attribute__((const, overloadable))
    convert_uint2(ulong2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint3 __attribute__((const, overloadable))
    convert_uint3(ulong3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern uint4 __attribute__((const, overloadable))
    convert_uint4(ulong4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(float2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(float3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(float4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(char2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(char3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(char4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(uchar2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(uchar3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(uchar4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(short2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(short3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(short4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(ushort2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(ushort3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(ushort4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(int2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(int3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(int4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double2 __attribute__((const, overloadable))
    convert_double2(uint2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double3 __attribute__((const, overloadable))
    convert_double3(uint3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern double4 __attribute__((const, overloadable))
    convert_double4(uint4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(float2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(float3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(float4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(char2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(char3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(char4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(uchar2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(uchar3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(uchar4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(short2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(short3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(short4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(ushort2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(ushort3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(ushort4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(int2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(int3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(int4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long2 __attribute__((const, overloadable))
    convert_long2(uint2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long3 __attribute__((const, overloadable))
    convert_long3(uint3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern long4 __attribute__((const, overloadable))
    convert_long4(uint4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(float2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(float3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(float4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(char2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(char3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(char4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(uchar2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(uchar3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(uchar4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(short2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(short3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(short4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(ushort2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(ushort3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(ushort4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(int2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(int3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(int4 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong2 __attribute__((const, overloadable))
    convert_ulong2(uint2 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong3 __attribute__((const, overloadable))
    convert_ulong3(uint3 v);
#endif

#if (defined(RS_VERSION) && (RS_VERSION >= 21))
extern ulong4 __attribute__((const, overloadable))
    convert_ulong4(uint4 v);
#endif

/*
 * rsPackColorTo8888: Create a uchar4 RGBA from floats
 *
 * Packs three or four floating point RGBA values into a uchar4.
 *
 * The input values are typically between 0.0 and 1.0 inclusive.  For input values outside
 * of this range, the resulting outputs will be clamped to be between 0 and 255.  As this
 * clamping may be done after the input is multiplied by 255.f and converted to an integer,
 * input numbers greater than INT_MAX/255.f or less than INT_MIN/255.f can result in
 * undefined behavior.
 *
 * If the alpha component is not specified, it is assumed to be 1.0, i.e. the result will
 * have an alpha set to 255.
 *
 * Parameters:
 *   r: Red component.
 *   g: Green component.
 *   b: Blue component.
 *   a: Alpha component.
 *   color: Vector of 3 or 4 floats containing the R, G, B, and A values.
 */
extern uchar4 __attribute__((const, overloadable))
    rsPackColorTo8888(float r, float g, float b);

extern uchar4 __attribute__((const, overloadable))
    rsPackColorTo8888(float r, float g, float b, float a);

extern uchar4 __attribute__((const, overloadable))
    rsPackColorTo8888(float3 color);

extern uchar4 __attribute__((const, overloadable))
    rsPackColorTo8888(float4 color);

/*
 * rsUnpackColor8888: Create a float4 RGBA from uchar4
 *
 * Unpacks a uchar4 color to float4.  The resulting floats will be between 0.0 and 1.0 inclusive.
 */
extern float4 __attribute__((const))
    rsUnpackColor8888(uchar4 c);

/*
 * rsYuvToRGBA: Convert a YUV value to RGBA
 *
 * Converts a color from a YUV representation to RGBA.
 *
 * We currently don't provide a function to do the reverse conversion.
 *
 * Parameters:
 *   y: Luminance component.
 *   u: U chrominance component.
 *   v: V chrominance component.
 */
extern float4 __attribute__((const, overloadable))
    rsYuvToRGBA_float4(uchar y, uchar u, uchar v);

extern uchar4 __attribute__((const, overloadable))
    rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);

#endif // RENDERSCRIPT_RS_CONVERT_RSH

{'repo_name': 'honghuachen/Usdk', 'stars': '139', 'repo_language': 'HTML', 'file_name': 'module.modulemap', 'mime_type': 'text/plain', 'hash': 7790727954317745752, 'source_dataset': 'data'}


import Foundation

public enum PMKError: Error {
    /**
     The completionHandler with form (T?, ErrorType?) was called with (nil, nil)
     This is invalid as per Cocoa/Apple calling conventions.
     */
    case invalidCallingConvention

    /**
     A handler returned its own promise. 99% of the time, this is likely a
     programming error. It is also invalid per Promises/A+.
     */
    case returnedSelf

    /** `when()`, `race()` etc. were called with invalid parameters, eg. an empty array. */
    case badInput

    /// The operation was cancelled
    case cancelled

    /// `nil` was returned from `flatMap`
    @available(*, deprecated, message: "See: `compactMap`")
    case flatMap(Any, Any.Type)

    case compactMap(Any, Any.Type)

    /// the lastValue or firstValue of a sequence was requested but the sequence was empty
    case emptySequence
}

extension PMKError: CustomDebugStringConvertible {
    public var debugDescription: String {
        switch self {
        case .flatMap(let obj, let type):
            return "Could not `flatMap<\(type)>`: \(obj)"
        case .compactMap(let obj, let type):
            return "Could not `compactMap<\(type)>`: \(obj)"
        case .invalidCallingConvention:
            return "A closure was called with an invalid calling convention, probably (nil, nil)"
        case .returnedSelf:
            return "A promise handler returned itself"
        case .badInput:
            return "Bad input was provided to a PromiseKit function"
        case .cancelled:
            return "The asynchronous sequence was cancelled"
        case .emptySequence:
            return "The first or last element was requested for an empty sequence"
        }
    }
}

extension PMKError: LocalizedError {
    public var errorDescription: String? {
        return debugDescription
    }
}

//////////////////////////////////////////////////////////// Cancellation

public protocol CancellableError: Error {
    var isCancelled: Bool { get }
}

extension Error {
    public var isCancelled: Bool {
        do {
            throw self
        } catch PMKError.cancelled {
            return true
        } catch let error as CancellableError {
            return error.isCancelled
        } catch URLError.cancelled {
            return true
        } catch CocoaError.userCancelled {
            return true
        } catch {
            return false
        }
    }
}

public enum CatchPolicy {
    case allErrors
    case allErrorsExceptCancellation
}

{'repo_name': 'airbnb/BuckSample', 'stars': '304', 'repo_language': 'Starlark', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': -9047764093654411149, 'source_dataset': 'data'}


name = 'TensorFlow'
version = '1.6.0'
local_cuda_ver = '9.1.85'
versionsuffix = '-Python-%%(pyver)s-CUDA-%s' % local_cuda_ver

homepage = 'https://www.tensorflow.org/'
description = "An open-source software library for Machine Intelligence"

toolchain = {'name': 'foss', 'version': '2018a'}
toolchainopts = {'pic': True}

source_urls = ['https://github.com/tensorflow/tensorflow/archive/']
sources = ['v%(version)s.tar.gz']
patches = [
    'TensorFlow-1.5.0_swig-env.patch',
    'TensorFlow-%(version)s_dont_expand_cuda_cudnn_path.patch',
    'TensorFlow-%(version)s_remove-msse-hardcoding.patch',
    'TensorFlow-%(version)s_lrt-flag.patch',
]
checksums = [
    '03cf1423446abbead6bd8c3cf6e6affa7d99746cd119691b012aac9a1795f4fb',  # v1.6.0.tar.gz
    '53807290f1acb6a0f2a84f1a0ad9f917ee131c304b3e08679f3cbd335b22c7ef',  # TensorFlow-1.5.0_swig-env.patch
    # TensorFlow-1.6.0_dont_expand_cuda_cudnn_path.patch
    'f490b35179ed5c864255950784d5677d02f6c83a1684d406dbd31e2607d342fa',
    '0ad82aab981721b1ed4881106d9accd43fe38b863ec147f6a16b278605012099',  # TensorFlow-1.6.0_remove-msse-hardcoding.patch
    'd8b262eea9ff94c94c90b8c51219d8f56085ccee4370525cce8beba3b2b91d38',  # TensorFlow-1.6.0_lrt-flag.patch
]

builddependencies = [
    ('Bazel', '0.11.0'),
    ('wheel', '0.30.0', '-Python-%(pyver)s'),
]
dependencies = [
    ('Python', '3.6.4'),
    ('cuDNN', '7.0.5', '-CUDA-%s' % local_cuda_ver, True),
]

with_mkl_dnn = False

cuda_compute_capabilities = ['3.0', '3.2', '3.5', '3.7', '5.0', '5.2', '5.3', '6.0', '6.1', '7.0']

moduleclass = 'lib'

{'repo_name': 'easybuilders/easybuild-easyconfigs', 'stars': '179', 'repo_language': 'Python', 'file_name': 'ifort', 'mime_type': 'text/x-shellscript', 'hash': 6021378335466565458, 'source_dataset': 'data'}


/*
 * This is the source code of Telegram for Android v. 5.x.x.
 * It is licensed under GNU GPL v. 2 or later.
 * You should have received a copy of the license in this archive (see LICENSE).
 *
 * Copyright Nikolai Kudashov, 2013-2018.
 */

package org.telegram.messenger;

import android.app.Activity;
import android.content.SharedPreferences;
import android.net.Uri;
import android.util.SparseArray;
import android.util.SparseIntArray;

import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;

import java.io.File;
import java.io.RandomAccessFile;
import java.util.ArrayList;

public class FileUploadOperation {

    private static class UploadCachedResult {
        private long bytesOffset;
        private byte[] iv;
    }

    private int currentAccount;
    private boolean isLastPart;
    private boolean nextPartFirst;
    private int operationGuid;
    private static final int minUploadChunkSize = 128;
    private static final int minUploadChunkSlowNetworkSize = 32;
    private static final int initialRequestsCount = 8;
    private static final int initialRequestsSlowNetworkCount = 1;
    private static final int maxUploadingKBytes = 1024 * 2;
    private static final int maxUploadingSlowNetworkKBytes = 32;
    private static final int maxUploadParts = (int) (FileLoader.MAX_FILE_SIZE / 1024 / 512);
    private int maxRequestsCount;
    private int uploadChunkSize = 64 * 1024;
    private boolean slowNetwork;
    private ArrayList<byte[]> freeRequestIvs;
    private int requestNum;
    private String uploadingFilePath;
    private int state;
    private byte[] readBuffer;
    private FileUploadOperationDelegate delegate;
    private SparseIntArray requestTokens = new SparseIntArray();
    private int currentPartNum;
    private long currentFileId;
    private long totalFileSize;
    private int totalPartsCount;
    private long readBytesCount;
    private long uploadedBytesCount;
    private int saveInfoTimes;
    private byte[] key;
    private byte[] iv;
    private byte[] ivChange;
    private boolean isEncrypted;
    private int fingerprint;
    private boolean isBigFile;
    private String fileKey;
    private int estimatedSize;
    private int uploadStartTime;
    private RandomAccessFile stream;
    private boolean started;
    private int currentUploadRequetsCount;
    private SharedPreferences preferences;
    private int currentType;
    private int lastSavedPartNum;
    private long availableSize;
    private boolean uploadFirstPartLater;
    private SparseArray<UploadCachedResult> cachedResults = new SparseArray<>();

    public interface FileUploadOperationDelegate {
        void didFinishUploadingFile(FileUploadOperation operation, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile, byte[] key, byte[] iv);
        void didFailedUploadingFile(FileUploadOperation operation);
        void didChangedUploadProgress(FileUploadOperation operation, long uploadedSize, long totalSize);
    }

    public FileUploadOperation(int instance, String location, boolean encrypted, int estimated, int type) {
        currentAccount = instance;
        uploadingFilePath = location;
        isEncrypted = encrypted;
        estimatedSize = estimated;
        currentType = type;
        uploadFirstPartLater = estimated != 0 && !isEncrypted;
    }

    public long getTotalFileSize() {
        return totalFileSize;
    }

    public void setDelegate(FileUploadOperationDelegate fileUploadOperationDelegate) {
        delegate = fileUploadOperationDelegate;
    }

    public void start() {
        if (state != 0) {
            return;
        }
        state = 1;
        Utilities.stageQueue.postRunnable(() -> {
            preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE);
            slowNetwork = ApplicationLoader.isConnectionSlow();
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("start upload on slow network = " + slowNetwork);
            }
            for (int a = 0, count = (slowNetwork ? initialRequestsSlowNetworkCount : initialRequestsCount); a < count; a++) {
                startUploadRequest();
            }
        });
    }

    protected void onNetworkChanged(final boolean slow) {
        if (state != 1) {
            return;
        }
        Utilities.stageQueue.postRunnable(() -> {
            if (slowNetwork != slow) {
                slowNetwork = slow;
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("network changed to slow = " + slowNetwork);
                }
                for (int a = 0; a < requestTokens.size(); a++) {
                    ConnectionsManager.getInstance(currentAccount).cancelRequest(requestTokens.valueAt(a), true);
                }
                requestTokens.clear();
                cleanup();
                isLastPart = false;
                nextPartFirst = false;
                requestNum = 0;
                currentPartNum = 0;
                readBytesCount = 0;
                uploadedBytesCount = 0;
                saveInfoTimes = 0;
                key = null;
                iv = null;
                ivChange = null;
                currentUploadRequetsCount = 0;
                lastSavedPartNum = 0;
                uploadFirstPartLater = false;
                cachedResults.clear();

                operationGuid++;
                for (int a = 0, count = (slowNetwork ? initialRequestsSlowNetworkCount : initialRequestsCount); a < count; a++) {
                    startUploadRequest();
                }
            }
        });
    }

    public void cancel() {
        if (state == 3) {
            return;
        }
        state = 2;
        Utilities.stageQueue.postRunnable(() -> {
            for (int a = 0; a < requestTokens.size(); a++) {
                ConnectionsManager.getInstance(currentAccount).cancelRequest(requestTokens.valueAt(a), true);
            }
        });
        delegate.didFailedUploadingFile(this);
        cleanup();
    }

    private void cleanup() {
        if (preferences == null) {
            preferences = ApplicationLoader.applicationContext.getSharedPreferences("uploadinfo", Activity.MODE_PRIVATE);
        }
        preferences.edit().remove(fileKey + "_time").
                remove(fileKey + "_size").
                remove(fileKey + "_uploaded").
                remove(fileKey + "_id").
                remove(fileKey + "_iv").
                remove(fileKey + "_key").
                remove(fileKey + "_ivc").commit();
        try {
            if (stream != null) {
                stream.close();
                stream = null;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    protected void checkNewDataAvailable(final long newAvailableSize, final long finalSize) {
        Utilities.stageQueue.postRunnable(() -> {
            if (estimatedSize != 0 && finalSize != 0) {
                estimatedSize = 0;
                totalFileSize = finalSize;
                calcTotalPartsCount();
                if (!uploadFirstPartLater && started) {
                    storeFileUploadInfo();
                }
            }
            availableSize = finalSize > 0 ? finalSize : newAvailableSize;
            if (currentUploadRequetsCount < maxRequestsCount) {
                startUploadRequest();
            }
        });
    }

    private void storeFileUploadInfo() {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt(fileKey + "_time", uploadStartTime);
        editor.putLong(fileKey + "_size", totalFileSize);
        editor.putLong(fileKey + "_id", currentFileId);
        editor.remove(fileKey + "_uploaded");
        if (isEncrypted) {
            editor.putString(fileKey + "_iv", Utilities.bytesToHex(iv));
            editor.putString(fileKey + "_ivc", Utilities.bytesToHex(ivChange));
            editor.putString(fileKey + "_key", Utilities.bytesToHex(key));
        }
        editor.commit();
    }

    private void calcTotalPartsCount() {
        if (uploadFirstPartLater) {
            if (isBigFile) {
                totalPartsCount = 1 + (int) ((totalFileSize - uploadChunkSize) + uploadChunkSize - 1) / uploadChunkSize;
            } else {
                totalPartsCount = 1 + (int) ((totalFileSize - 1024) + uploadChunkSize - 1) / uploadChunkSize;
            }
        } else {
            totalPartsCount = (int) (totalFileSize + uploadChunkSize - 1) / uploadChunkSize;
        }
    }

    private void startUploadRequest() {
        if (state != 1) {
            return;
        }

        final TLObject finalRequest;
        final int currentRequestPartNum;

        final int currentRequestBytes;
        final byte[] currentRequestIv;
        try {
            started = true;
            if (stream == null) {
                File cacheFile = new File(uploadingFilePath);
                if (AndroidUtilities.isInternalUri(Uri.fromFile(cacheFile))) {
                    throw new Exception("trying to upload internal file");
                }
                stream = new RandomAccessFile(cacheFile, "r");
                if (estimatedSize != 0) {
                    totalFileSize = estimatedSize;
                } else {
                    totalFileSize = cacheFile.length();
                }
                if (totalFileSize > 10 * 1024 * 1024) {
                    isBigFile = true;
                }

                uploadChunkSize = (int) Math.max(slowNetwork ? minUploadChunkSlowNetworkSize : minUploadChunkSize, (totalFileSize + 1024 * maxUploadParts - 1) / (1024 * maxUploadParts));
                if (1024 % uploadChunkSize != 0) {
                    int chunkSize = 64;
                    while (uploadChunkSize > chunkSize) {
                        chunkSize *= 2;
                    }
                    uploadChunkSize = chunkSize;
                }
                maxRequestsCount = Math.max(1, (slowNetwork ? maxUploadingSlowNetworkKBytes : maxUploadingKBytes) / uploadChunkSize);

                if (isEncrypted) {
                    freeRequestIvs = new ArrayList<>(maxRequestsCount);
                    for (int a = 0; a < maxRequestsCount; a++) {
                        freeRequestIvs.add(new byte[32]);
                    }
                }

                uploadChunkSize *= 1024;
                calcTotalPartsCount();
                readBuffer = new byte[uploadChunkSize];

                fileKey = Utilities.MD5(uploadingFilePath + (isEncrypted ? "enc" : ""));
                long fileSize = preferences.getLong(fileKey + "_size", 0);
                uploadStartTime = (int)(System.currentTimeMillis() / 1000);
                boolean rewrite = false;
                if (!uploadFirstPartLater && !nextPartFirst && estimatedSize == 0 && fileSize == totalFileSize) {
                    currentFileId = preferences.getLong(fileKey + "_id", 0);
                    int date = preferences.getInt(fileKey + "_time", 0);
                    long uploadedSize = preferences.getLong(fileKey + "_uploaded", 0);
                    if (isEncrypted) {
                        String ivString = preferences.getString(fileKey + "_iv", null);
                        String keyString = preferences.getString(fileKey + "_key", null);
                        if (ivString != null && keyString != null) {
                            key = Utilities.hexToBytes(keyString);
                            iv = Utilities.hexToBytes(ivString);
                            if (key != null && iv != null && key.length == 32 && iv.length == 32) {
                                ivChange = new byte[32];
                                System.arraycopy(iv, 0, ivChange, 0, 32);
                            } else {
                                rewrite = true;
                            }
                        } else {
                            rewrite = true;
                        }
                    }
                    if (!rewrite && date != 0) {
                        if (isBigFile && date < uploadStartTime - 60 * 60 * 24) {
                            date = 0;
                        } else if (!isBigFile && date < uploadStartTime - 60 * 60 * 1.5f) {
                            date = 0;
                        }
                        if (date != 0) {
                            if (uploadedSize > 0) {
                                readBytesCount = uploadedSize;
                                currentPartNum = (int) (uploadedSize / uploadChunkSize);
                                if (!isBigFile) {
                                    for (int b = 0; b < readBytesCount / uploadChunkSize; b++) {
                                        int bytesRead = stream.read(readBuffer);
                                        int toAdd = 0;
                                        if (isEncrypted && bytesRead % 16 != 0) {
                                            toAdd += 16 - bytesRead % 16;
                                        }
                                        NativeByteBuffer sendBuffer = new NativeByteBuffer(bytesRead + toAdd);
                                        if (bytesRead != uploadChunkSize || totalPartsCount == currentPartNum + 1) {
                                            isLastPart = true;
                                        }
                                        sendBuffer.writeBytes(readBuffer, 0, bytesRead);
                                        if (isEncrypted) {
                                            for (int a = 0; a < toAdd; a++) {
                                                sendBuffer.writeByte(0);
                                            }
                                            Utilities.aesIgeEncryption(sendBuffer.buffer, key, ivChange, true, true, 0, bytesRead + toAdd);
                                        }
                                        sendBuffer.reuse();
                                    }
                                } else {
                                    stream.seek(uploadedSize);
                                    if (isEncrypted) {
                                        String ivcString = preferences.getString(fileKey + "_ivc", null);
                                        if (ivcString != null) {
                                            ivChange = Utilities.hexToBytes(ivcString);
                                            if (ivChange == null || ivChange.length != 32) {
                                                rewrite = true;
                                                readBytesCount = 0;
                                                currentPartNum = 0;
                                            }
                                        } else {
                                            rewrite = true;
                                            readBytesCount = 0;
                                            currentPartNum = 0;
                                        }
                                    }
                                }
                            } else {
                                rewrite = true;
                            }
                        }
                    } else {
                        rewrite = true;
                    }
                } else {
                    rewrite = true;
                }
                if (rewrite) {
                    if (isEncrypted) {
                        iv = new byte[32];
                        key = new byte[32];
                        ivChange = new byte[32];
                        Utilities.random.nextBytes(iv);
                        Utilities.random.nextBytes(key);
                        System.arraycopy(iv, 0, ivChange, 0, 32);
                    }
                    currentFileId = Utilities.random.nextLong();
                    if (!nextPartFirst && !uploadFirstPartLater && estimatedSize == 0) {
                        storeFileUploadInfo();
                    }
                }

                if (isEncrypted) {
                    try {
                        java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
                        byte[] arr = new byte[64];
                        System.arraycopy(key, 0, arr, 0, 32);
                        System.arraycopy(iv, 0, arr, 32, 32);
                        byte[] digest = md.digest(arr);
                        for (int a = 0; a < 4; a++) {
                            fingerprint |= ((digest[a] ^ digest[a + 4]) & 0xFF) << (a * 8);
                        }
                    } catch (Exception e) {
                        FileLog.e(e);
                    }
                }
                uploadedBytesCount = readBytesCount;
                lastSavedPartNum = currentPartNum;

                if (uploadFirstPartLater) {
                    if (isBigFile) {
                        stream.seek(uploadChunkSize);
                        readBytesCount = uploadChunkSize;
                    } else {
                        stream.seek(1024);
                        readBytesCount = 1024;
                    }
                    currentPartNum = 1;
                }
            }

            if (estimatedSize != 0) {
                if (readBytesCount + uploadChunkSize > availableSize) {
                    return;
                }
            }

            if (nextPartFirst) {
                stream.seek(0);
                if (isBigFile) {
                    currentRequestBytes = stream.read(readBuffer);
                } else {
                    currentRequestBytes = stream.read(readBuffer, 0, 1024);
                }
                currentPartNum = 0;
            } else {
                currentRequestBytes = stream.read(readBuffer);
            }
            if (currentRequestBytes == -1) {
                return;
            }
            int toAdd = 0;
            if (isEncrypted && currentRequestBytes % 16 != 0) {
                toAdd += 16 - currentRequestBytes % 16;
            }
            NativeByteBuffer sendBuffer = new NativeByteBuffer(currentRequestBytes + toAdd);
            if (nextPartFirst || currentRequestBytes != uploadChunkSize || estimatedSize == 0 && totalPartsCount == currentPartNum + 1) {
                if (uploadFirstPartLater) {
                    nextPartFirst = true;
                    uploadFirstPartLater = false;
                } else {
                    isLastPart = true;
                }
            }
            sendBuffer.writeBytes(readBuffer, 0, currentRequestBytes);
            if (isEncrypted) {
                for (int a = 0; a < toAdd; a++) {
                    sendBuffer.writeByte(0);
                }
                Utilities.aesIgeEncryption(sendBuffer.buffer, key, ivChange, true, true, 0, currentRequestBytes + toAdd);
                currentRequestIv = freeRequestIvs.get(0);
                System.arraycopy(ivChange, 0, currentRequestIv, 0, 32);
                freeRequestIvs.remove(0);
            } else {
                currentRequestIv = null;
            }
            if (isBigFile) {
                TLRPC.TL_upload_saveBigFilePart req = new TLRPC.TL_upload_saveBigFilePart();
                req.file_part = currentRequestPartNum = currentPartNum;
                req.file_id = currentFileId;
                if (estimatedSize != 0) {
                    req.file_total_parts = -1;
                } else {
                    req.file_total_parts = totalPartsCount;
                }
                req.bytes = sendBuffer;
                finalRequest = req;
            } else {
                TLRPC.TL_upload_saveFilePart req = new TLRPC.TL_upload_saveFilePart();
                req.file_part = currentRequestPartNum = currentPartNum;
                req.file_id = currentFileId;
                req.bytes = sendBuffer;
                finalRequest = req;
            }
            if (isLastPart && nextPartFirst) {
                nextPartFirst = false;
                currentPartNum = totalPartsCount - 1;
                stream.seek(totalFileSize);
            }
            readBytesCount += currentRequestBytes;
        } catch (Exception e) {
            FileLog.e(e);
            state = 4;
            delegate.didFailedUploadingFile(this);
            cleanup();
            return;
        }
        currentPartNum++;
        currentUploadRequetsCount++;
        final int requestNumFinal = requestNum++;
        final long currentRequestBytesOffset = currentRequestPartNum + currentRequestBytes;
        final int requestSize = finalRequest.getObjectSize() + 4;
        final int currentOperationGuid = operationGuid;

        int connectionType;
        if (slowNetwork) {
            connectionType = ConnectionsManager.ConnectionTypeUpload;
        } else {
            connectionType = ConnectionsManager.ConnectionTypeUpload | ((requestNumFinal % 4) << 16);
        }

        int requestToken = ConnectionsManager.getInstance(currentAccount).sendRequest(finalRequest, (response, error) -> {
            if (currentOperationGuid != operationGuid) {
                return;
            }
            int networkType = response != null ? response.networkType : ApplicationLoader.getCurrentNetworkType();
            if (currentType == ConnectionsManager.FileTypeAudio) {
                StatsController.getInstance(currentAccount).incrementSentBytesCount(networkType, StatsController.TYPE_AUDIOS, requestSize);
            } else if (currentType == ConnectionsManager.FileTypeVideo) {
                StatsController.getInstance(currentAccount).incrementSentBytesCount(networkType, StatsController.TYPE_VIDEOS, requestSize);
            } else if (currentType == ConnectionsManager.FileTypePhoto) {
                StatsController.getInstance(currentAccount).incrementSentBytesCount(networkType, StatsController.TYPE_PHOTOS, requestSize);
            } else if (currentType == ConnectionsManager.FileTypeFile) {
                StatsController.getInstance(currentAccount).incrementSentBytesCount(networkType, StatsController.TYPE_FILES, requestSize);
            }
            if (currentRequestIv != null) {
                freeRequestIvs.add(currentRequestIv);
            }
            requestTokens.delete(requestNumFinal);
            if (response instanceof TLRPC.TL_boolTrue) {
                if (state != 1) {
                    return;
                }
                uploadedBytesCount += currentRequestBytes;
                long size;
                if (estimatedSize != 0) {
                    size = Math.max(availableSize, estimatedSize);
                } else {
                    size = totalFileSize;
                }
                delegate.didChangedUploadProgress(FileUploadOperation.this, uploadedBytesCount, size);
                currentUploadRequetsCount--;
                if (isLastPart && currentUploadRequetsCount == 0 && state == 1) {
                    state = 3;
                    if (key == null) {
                        TLRPC.InputFile result;
                        if (isBigFile) {
                            result = new TLRPC.TL_inputFileBig();
                        } else {
                            result = new TLRPC.TL_inputFile();
                            result.md5_checksum = "";
                        }
                        result.parts = currentPartNum;
                        result.id = currentFileId;
                        result.name = uploadingFilePath.substring(uploadingFilePath.lastIndexOf("/") + 1);
                        delegate.didFinishUploadingFile(FileUploadOperation.this, result, null, null, null);
                        cleanup();
                    } else {
                        TLRPC.InputEncryptedFile result;
                        if (isBigFile) {
                            result = new TLRPC.TL_inputEncryptedFileBigUploaded();
                        } else {
                            result = new TLRPC.TL_inputEncryptedFileUploaded();
                            result.md5_checksum = "";
                        }
                        result.parts = currentPartNum;
                        result.id = currentFileId;
                        result.key_fingerprint = fingerprint;
                        delegate.didFinishUploadingFile(FileUploadOperation.this, null, result, key, iv);
                        cleanup();
                    }
                    if (currentType == ConnectionsManager.FileTypeAudio) {
                        StatsController.getInstance(currentAccount).incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_AUDIOS, 1);
                    } else if (currentType == ConnectionsManager.FileTypeVideo) {
                        StatsController.getInstance(currentAccount).incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_VIDEOS, 1);
                    } else if (currentType == ConnectionsManager.FileTypePhoto) {
                        StatsController.getInstance(currentAccount).incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_PHOTOS, 1);
                    } else if (currentType == ConnectionsManager.FileTypeFile) {
                        StatsController.getInstance(currentAccount).incrementSentItemsCount(ApplicationLoader.getCurrentNetworkType(), StatsController.TYPE_FILES, 1);
                    }
                } else if (currentUploadRequetsCount < maxRequestsCount) {
                    if (estimatedSize == 0 && !uploadFirstPartLater && !nextPartFirst) {
                        if (saveInfoTimes >= 4) {
                            saveInfoTimes = 0;
                        }
                        if (currentRequestPartNum == lastSavedPartNum) {
                            lastSavedPartNum++;
                            long offsetToSave = currentRequestBytesOffset;
                            byte[] ivToSave = currentRequestIv;
                            UploadCachedResult result;
                            while ((result = cachedResults.get(lastSavedPartNum)) != null) {
                                offsetToSave = result.bytesOffset;
                                ivToSave = result.iv;
                                cachedResults.remove(lastSavedPartNum);
                                lastSavedPartNum++;
                            }
                            if (isBigFile && offsetToSave % (1024 * 1024) == 0 || !isBigFile && saveInfoTimes == 0) {
                                SharedPreferences.Editor editor = preferences.edit();
                                editor.putLong(fileKey + "_uploaded", offsetToSave);
                                if (isEncrypted) {
                                    editor.putString(fileKey + "_ivc", Utilities.bytesToHex(ivToSave));
                                }
                                editor.commit();
                            }
                        } else {
                            UploadCachedResult result = new UploadCachedResult();
                            result.bytesOffset = currentRequestBytesOffset;
                            if (currentRequestIv != null) {
                                result.iv = new byte[32];
                                System.arraycopy(currentRequestIv, 0, result.iv, 0, 32);
                            }
                            cachedResults.put(currentRequestPartNum, result);
                        }
                        saveInfoTimes++;
                    }
                    startUploadRequest();
                }
            } else {
                if (finalRequest != null) {
                    FileLog.e("23123");
                }
                state = 4;
                delegate.didFailedUploadingFile(FileUploadOperation.this);
                cleanup();
            }
        }, null, () -> Utilities.stageQueue.postRunnable(() -> {
            if (currentUploadRequetsCount < maxRequestsCount) {
                startUploadRequest();
            }
        }), 0, ConnectionsManager.DEFAULT_DATACENTER_ID, connectionType, true);
        requestTokens.put(requestNumFinal, requestToken);
    }
}

{'repo_name': 'DrKLO/Telegram', 'stars': '14377', 'repo_language': 'Java', 'file_name': 'p256_32.h', 'mime_type': 'text/x-c', 'hash': 1064836971782792474, 'source_dataset': 'data'}


/*
 * wnc_cpld.c - A driver for control wnc_cpld base on lm75.c
 *
 * Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
 * Copyright (c) 2017 WNC <wnc@wnc.com.tw>
 *
 * This program 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>

/* Addresses scanned */
static const unsigned short normal_i2c[] = { 0x31, 0x32, I2C_CLIENT_END };

/* Size of EEPROM in bytes */
#define CPLD_SIZE 3

/* Each client has this additional data */
struct cpld_data {
	struct mutex		update_lock;
	char			valid;		 /* !=0 if registers are valid */
	unsigned long		last_updated;    /* In jiffies */
	u8			data[CPLD_SIZE]; /* Register value */
};

static ssize_t show_value(struct device *dev, struct device_attribute *da, char *buf)
{
	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
	struct i2c_client *client = to_i2c_client(dev);
	struct cpld_data *data = i2c_get_clientdata(client);

	mutex_lock(&data->update_lock);
	data->data[0] = i2c_smbus_read_byte_data(client, attr->index);
	mutex_unlock(&data->update_lock);

	return sprintf(buf, "%02x\n", data->data[0]);
}

static ssize_t set_value(struct device *dev, struct device_attribute *da, const char *buf, size_t count)
{
	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
	struct i2c_client *client = to_i2c_client(dev);
	struct cpld_data *data = i2c_get_clientdata(client);
	u8 temp;
	int error;

	error = kstrtou8(buf, 10, &temp);
	if (error)
		return error;

	mutex_lock(&data->update_lock);
	i2c_smbus_write_byte_data(client, attr->index, temp);
	mutex_unlock(&data->update_lock);

	return count;
}

static SENSOR_DEVICE_ATTR(reset_control, S_IWUSR | S_IRUGO, show_value, set_value, 2);
static SENSOR_DEVICE_ATTR(sfp_mod_abs1, S_IRUGO, show_value, NULL, 3);
static SENSOR_DEVICE_ATTR(sfp_mod_abs2, S_IRUGO, show_value, NULL, 4);
static SENSOR_DEVICE_ATTR(sfp_mod_abs3, S_IRUGO, show_value, NULL, 5);
static SENSOR_DEVICE_ATTR(sfp_mod_abs4, S_IRUGO, show_value, NULL, 6);
static SENSOR_DEVICE_ATTR(qsfp_modprs, S_IRUGO, show_value, NULL, 22);
static SENSOR_DEVICE_ATTR(qsfp_lpmode, S_IWUSR | S_IRUGO, show_value, set_value, 24);

static struct attribute *cpld2_attributes[] = {
	&sensor_dev_attr_reset_control.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs1.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs2.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs3.dev_attr.attr,
	&sensor_dev_attr_qsfp_modprs.dev_attr.attr,
	&sensor_dev_attr_qsfp_lpmode.dev_attr.attr,
	NULL
};

static struct attribute *cpld1_attributes[] = {
	&sensor_dev_attr_sfp_mod_abs1.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs2.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs3.dev_attr.attr,
	&sensor_dev_attr_sfp_mod_abs4.dev_attr.attr,
	NULL
};

static const struct attribute_group cpld2_group = {
	.attrs = cpld2_attributes,
};

static const struct attribute_group cpld1_group = {
	.attrs = cpld1_attributes,
};

/* Return 0 if detection is successful, -ENODEV otherwise */
static int cpld_detect(struct i2c_client *new_client, struct i2c_board_info *info)
{
	struct i2c_adapter *adapter = new_client->adapter;
	int conf;

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
				     I2C_FUNC_SMBUS_WORD_DATA))
		return -ENODEV;

	/* Unused bits */
	conf = i2c_smbus_read_byte_data(new_client, 0);
	if (!conf)
		return -ENODEV;

	return 0;
}

static int cpld_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct cpld_data *data;
	int status;

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		return -EIO;
#if 1
	data = devm_kzalloc(&client->dev, sizeof(struct cpld_data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	i2c_set_clientdata(client, data);
	mutex_init(&data->update_lock);
#endif

	if (client->addr == 49) /* 0x31 */
		/* Register sysfs hooks */
		status = sysfs_create_group(&client->dev.kobj, &cpld1_group);
	else if (client->addr == 50) /* 0x32 */
		/* Register sysfs hooks */
		status = sysfs_create_group(&client->dev.kobj, &cpld2_group);
	else
		status = 1;

	if (status)
		return status;

	dev_info(&client->dev, "cpld 0x%x found\n", client->addr);

	return 0;
}

static int cpld_remove(struct i2c_client *client)
{
	if (client->addr == 49) /* 0x31 */
		sysfs_remove_group(&client->dev.kobj, &cpld1_group);
	else if (client->addr == 50) /* 0x32 */
		sysfs_remove_group(&client->dev.kobj, &cpld2_group);
	else
		return 1;

	return 0;
}

static const struct i2c_device_id cpld_id[] = {
	{ "wnc_cpld", 0 },
	{}
};
MODULE_DEVICE_TABLE(i2c, cpld_id);

static struct i2c_driver cpld_driver = {
	.class		= I2C_CLASS_HWMON,
	.driver = {
		.name	= "wnc_cpld",
	},
	.probe		= cpld_probe,
	.remove		= cpld_remove,
	.id_table	= cpld_id,
	.detect		= cpld_detect,
	.address_list	= normal_i2c,
};

module_i2c_driver(cpld_driver);

MODULE_AUTHOR("WNC <wnc@wnc.com.tw>");
MODULE_DESCRIPTION("WNC CPLD driver");
MODULE_LICENSE("GPL");

{'repo_name': 'Azure/sonic-buildimage', 'stars': '234', 'repo_language': 'C', 'file_name': 'Dockerfile.j2', 'mime_type': 'text/plain', 'hash': 3242919606210100936, 'source_dataset': 'data'}


//
//  BookmarkIDCloudStoreTests.swift
//  FreetimeTests
//
//  Created by Ryan Nystrom on 11/24/18.
//  Copyright © 2018 Ryan Nystrom. All rights reserved.
//

import XCTest
@testable import Freetime

class FakeBookmarkCloudStoreListener: BookmarkIDCloudStoreListener {
    var updateCount = 0
    func didUpdateBookmarks(in store: BookmarkIDCloudStore) {
        updateCount += 1
    }
}

class BookmarkIDCloudStoreTests: XCTestCase {

    override func setUp() {
        let domain = Bundle.main.bundleIdentifier!
        UserDefaults.standard.removePersistentDomain(forName: domain)
    }

    func test_whenAdd_thatListenerNotified() {
        let listeners = [
            FakeBookmarkCloudStoreListener(),
            FakeBookmarkCloudStoreListener()
        ]
        let store = BookmarkIDCloudStore(username: "foo", iCloudStore: UserDefaults.standard)
        listeners.forEach { store.add(listener: $0) }

        store.add(graphQLID: "bar")
        XCTAssertTrue(store.contains(graphQLID: "bar"))
        XCTAssertFalse(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["bar"])
        XCTAssertEqual(listeners[0].updateCount, 1)
        XCTAssertEqual(listeners[1].updateCount, 1)

        store.add(graphQLID: "bar")
        XCTAssertEqual(store.ids, ["bar"])
        XCTAssertEqual(listeners[0].updateCount, 1)
        XCTAssertEqual(listeners[1].updateCount, 1)

        store.add(graphQLID: "baz")
        XCTAssertTrue(store.contains(graphQLID: "bar"))
        XCTAssertTrue(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["bar", "baz"])
        XCTAssertEqual(listeners[0].updateCount, 2)
        XCTAssertEqual(listeners[1].updateCount, 2)

        store.remove(graphQLID: "bar")
        XCTAssertFalse(store.contains(graphQLID: "bar"))
        XCTAssertTrue(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["baz"])
        XCTAssertEqual(listeners[0].updateCount, 3)
        XCTAssertEqual(listeners[1].updateCount, 3)

        store.remove(graphQLID: "bar")
        XCTAssertFalse(store.contains(graphQLID: "bar"))
        XCTAssertTrue(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["baz"])
        XCTAssertEqual(listeners[0].updateCount, 3)
        XCTAssertEqual(listeners[1].updateCount, 3)

        store.iCloudDidUpdate()
        XCTAssertEqual(listeners[0].updateCount, 4)
        XCTAssertEqual(listeners[1].updateCount, 4)
    }

    func test_whenAddArray_thatListenerNotified() {
        let listeners = [
            FakeBookmarkCloudStoreListener(),
            FakeBookmarkCloudStoreListener()
        ]
        let store = BookmarkIDCloudStore(username: "foo", iCloudStore: UserDefaults.standard)
        listeners.forEach { store.add(listener: $0) }

        store.add(graphQLIDs: ["bar"])
        XCTAssertTrue(store.contains(graphQLID: "bar"))
        XCTAssertFalse(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["bar"])
        XCTAssertEqual(listeners[0].updateCount, 1)
        XCTAssertEqual(listeners[1].updateCount, 1)

        store.add(graphQLIDs: ["bar", "baz"])
        XCTAssertTrue(store.contains(graphQLID: "bar"))
        XCTAssertTrue(store.contains(graphQLID: "baz"))
        XCTAssertEqual(store.ids, ["bar", "baz"])
        XCTAssertEqual(listeners[0].updateCount, 2)
        XCTAssertEqual(listeners[1].updateCount, 2)
    }

    func test_onRemove() {
        let store = BookmarkIDCloudStore(username: "foo", iCloudStore: UserDefaults.standard)

        store.add(graphQLID: "bar")
        XCTAssertEqual(store.ids, ["bar"])

        store.remove(graphQLID: "baz")
        XCTAssertEqual(store.ids, ["bar"])

        store.remove(graphQLID: "bar")
        XCTAssertEqual(store.ids, [])
    }

}

{'repo_name': 'GitHawkApp/GitHawk', 'stars': '2688', 'repo_language': 'Swift', 'file_name': 'Freetime-AppCenter.xcscheme', 'mime_type': 'text/xml', 'hash': 2875862674458903588, 'source_dataset': 'data'}


/*
 * Copyright 2017-2020 the original author or authors.
 *
 * 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
 *
 *      https://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.
 */
package org.springframework.hateoas.mediatype;

import static org.assertj.core.api.Assertions.*;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.Value;

import java.lang.reflect.Method;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

import org.junit.jupiter.api.Test;
import org.springframework.core.ResolvableType;
import org.springframework.hateoas.AffordanceModel.InputPayloadMetadata;
import org.springframework.hateoas.AffordanceModel.PayloadMetadata;
import org.springframework.hateoas.AffordanceModel.PropertyMetadata;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.server.core.MethodParameters;
import org.springframework.hateoas.support.Employee;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * @author Greg Turnquist
 */
class PropertyUtilsTest {

	@Test
	void simpleObject() {

		Employee employee = new Employee("Frodo Baggins", "ring bearer");

		Map<String, Object> properties = PropertyUtils.extractPropertyValues(employee);

		assertThat(properties).hasSize(2);
		assertThat(properties.keySet()).contains("name", "role");
		assertThat(properties.get("name")).isEqualTo("Frodo Baggins");
		assertThat(properties.get("role")).isEqualTo("ring bearer");
	}

	@Test
	void simpleObjectWrappedAsResource() {

		Employee employee = new Employee("Frodo Baggins", "ring bearer");
		EntityModel<Employee> employeeResource = EntityModel.of(employee);

		Map<String, Object> properties = PropertyUtils.extractPropertyValues(employeeResource);

		assertThat(properties).hasSize(2);
		assertThat(properties.keySet()).contains("name", "role");
		assertThat(properties.get("name")).isEqualTo("Frodo Baggins");
		assertThat(properties.get("role")).isEqualTo("ring bearer");
	}

	@Test
	void resourceWrappedSpringMvcParameter() {

		Method method = ReflectionUtils.findMethod(TestController.class, "newEmployee", EntityModel.class);
		MethodParameters parameters = MethodParameters.of(method);

		ResolvableType resolvableType = parameters.getParametersWith(RequestBody.class).stream() //
				.findFirst().map(it -> ResolvableType.forMethodParameter(it.getMethod(), it.getParameterIndex()))
				.orElseThrow(() -> new RuntimeException("Didn't find a parameter annotated with @RequestBody!"));

		InputPayloadMetadata metadata = PropertyUtils.getExposedProperties(resolvableType);

		assertThat(metadata.stream()).hasSize(2);
		assertThat(metadata.stream().map(PropertyMetadata::getName)).contains("name", "role");
	}

	@Test
	void objectWithIgnorableAttributes() {

		EmployeeWithCustomizedReaders employee = new EmployeeWithCustomizedReaders("Frodo", "Baggins", "ring bearer",
				"password", "fbaggins", "ignore this one");

		Map<String, Object> properties = PropertyUtils.extractPropertyValues(employee);

		assertThat(properties).hasSize(6);
		assertThat(properties.keySet()).containsExactlyInAnyOrder("firstName", "lastName", "role", "username", "fullName",
				"usernameAndLastName");
		assertThat(properties.entrySet()).containsExactlyInAnyOrder(new SimpleEntry<>("firstName", "Frodo"),
				new SimpleEntry<>("lastName", "Baggins"), new SimpleEntry<>("role", "ring bearer"),
				new SimpleEntry<>("username", "fbaggins"), new SimpleEntry<>("fullName", "Frodo Baggins"),
				new SimpleEntry<>("usernameAndLastName", "fbaggins+++Baggins"));
	}

	@Test
	void objectWithNullReturningGetter() {

		EmployeeWithNullReturningGetter employee = new EmployeeWithNullReturningGetter("Frodo");

		Map<String, Object> properties = PropertyUtils.extractPropertyValues(employee);

		assertThat(properties).hasSize(2);
		assertThat(properties.keySet()).containsExactlyInAnyOrder("name", "father");
		assertThat(properties.entrySet()).containsExactlyInAnyOrder(new SimpleEntry<>("name", "Frodo"),
				new SimpleEntry<>("father", null));
	}

	@Test
	void considersAccessorAvailablility() {

		PayloadMetadata metadata = PropertyUtils.getExposedProperties(MethodExposurePayload.class);

		assertThat(metadata.getPropertyMetadata("readWrite")) //
				.map(PropertyMetadata::isReadOnly) //
				.hasValue(false);

		assertThat(metadata.getPropertyMetadata("readOnly")) //
				.map(PropertyMetadata::isReadOnly) //
				.hasValue(true);
	}

	@Test
	void considersJsr303Annotations() {

		InputPayloadMetadata metadata = PropertyUtils.getExposedProperties(Jsr303SamplePayload.class);

		assertThat(metadata.getPropertyMetadata("nonNull")).hasValueSatisfying(it -> {
			assertThat(it.isRequired()).isTrue();
		});

		assertThat(metadata.getPropertyMetadata("pattern")).hasValueSatisfying(it -> {
			assertThat(it.getPattern()).hasValue("\\w");
		});

		assertThat(metadata.getPropertyMetadata("annotated")).hasValueSatisfying(it -> {
			assertThat(it.getPattern()).hasValue("regex");
		});
	}

	@Test // #1121
	void considersPropertyWithoutReader() throws Exception {

		InputPayloadMetadata metadata = PropertyUtils.getExposedProperties(WithoutReaderMethod.class);

		assertThat(metadata.getPropertyMetadata("firstname")).isPresent();
	}

	@Data
	@AllArgsConstructor
	@JsonIgnoreProperties({ "ignoreThisProperty" })
	static class EmployeeWithCustomizedReaders {

		private String firstName;
		private String lastName;
		private String role;
		@JsonIgnore private String password;
		@JsonIgnore(false) private String username;
		private String ignoreThisProperty;

		public String getFullName() {
			return this.firstName + " " + this.lastName;
		}

		@JsonIgnore
		public String getEncodedPassword() {
			return "{bcrypt}" + this.password;
		}

		@JsonIgnore(false)
		public String getUsernameAndLastName() {
			return this.username + "+++" + this.lastName;
		}
	}

	@Data
	static class EmployeeWithNullReturningGetter {

		private String name;
		private String father;

		EmployeeWithNullReturningGetter(String name) {
			this.name = name;
		}
	}

	@Value
	static class Jsr303SamplePayload {

		@NotNull String nonNull;
		@Pattern(regexp = "\\w") String pattern;
		TypeAnnotated annotated;
	}

	@Pattern(regexp = "regex")
	static class TypeAnnotated {}

	static class MethodExposurePayload {

		@Getter @Setter String readWrite;
		@Getter String readOnly;
	}

	@RestController
	static class TestController {

		@GetMapping("/")
		public Employee newEmployee(@RequestBody EntityModel<Employee> employee) {
			return employee.getContent();
		}
	}

	static class WithoutReaderMethod {

		private String firstname;

		public void setFirstname(String firstname) {
			this.firstname = firstname;
		}
	}
}

{'repo_name': 'spring-projects/spring-hateoas', 'stars': '879', 'repo_language': 'Java', 'file_name': 'eclipse-formatting.xml', 'mime_type': 'text/xml', 'hash': -6097358865931378816, 'source_dataset': 'data'}