text
stringlengths 2
99.9k
| meta
dict |
---|---|
/*-
* Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/ipfw/ip_fw2.c 200601 2009-12-16 10:48:40Z luigi $");
/*
* The FreeBSD IP packet firewall, main file
*/
#include "opt_ipfw.h"
#include "opt_ipdivert.h"
#include "opt_inet.h"
#ifndef INET
#error "IPFIREWALL requires INET"
#endif /* INET */
#include "opt_inet6.h"
#include "opt_ipsec.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/condvar.h>
#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/jail.h>
#include <sys/module.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/ucred.h>
#include <net/ethernet.h> /* for ETHERTYPE_IP */
#include <net/if.h>
#include <net/route.h>
#include <net/pf_mtag.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_fw.h>
#include <netinet/ipfw/ip_fw_private.h>
#include <netinet/ip_carp.h>
#include <netinet/pim.h>
#include <netinet/tcp_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/sctp.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#ifdef INET6
#include <netinet6/in6_pcb.h>
#include <netinet6/scope6_var.h>
#include <netinet6/ip6_var.h>
#endif
#include <machine/in_cksum.h> /* XXX for in_cksum */
#ifdef MAC
#include <security/mac/mac_framework.h>
#endif
/*
* static variables followed by global ones.
* All ipfw global variables are here.
*/
/* ipfw_vnet_ready controls when we are open for business */
static VNET_DEFINE(int, ipfw_vnet_ready) = 0;
#define V_ipfw_vnet_ready VNET(ipfw_vnet_ready)
static VNET_DEFINE(int, fw_deny_unknown_exthdrs);
#define V_fw_deny_unknown_exthdrs VNET(fw_deny_unknown_exthdrs)
#ifdef IPFIREWALL_DEFAULT_TO_ACCEPT
static int default_to_accept = 1;
#else
static int default_to_accept;
#endif
VNET_DEFINE(int, autoinc_step);
/*
* Each rule belongs to one of 32 different sets (0..31).
* The variable set_disable contains one bit per set.
* If the bit is set, all rules in the corresponding set
* are disabled. Set RESVD_SET(31) is reserved for the default rule
* and rules that are not deleted by the flush command,
* and CANNOT be disabled.
* Rules in set RESVD_SET can only be deleted individually.
*/
VNET_DEFINE(u_int32_t, set_disable);
#define V_set_disable VNET(set_disable)
VNET_DEFINE(int, fw_verbose);
/* counter for ipfw_log(NULL...) */
VNET_DEFINE(u_int64_t, norule_counter);
VNET_DEFINE(int, verbose_limit);
/* layer3_chain contains the list of rules for layer 3 */
VNET_DEFINE(struct ip_fw_chain, layer3_chain);
ipfw_nat_t *ipfw_nat_ptr = NULL;
struct cfg_nat *(*lookup_nat_ptr)(struct nat_list *, int);
ipfw_nat_cfg_t *ipfw_nat_cfg_ptr;
ipfw_nat_cfg_t *ipfw_nat_del_ptr;
ipfw_nat_cfg_t *ipfw_nat_get_cfg_ptr;
ipfw_nat_cfg_t *ipfw_nat_get_log_ptr;
#ifdef SYSCTL_NODE
uint32_t dummy_def = IPFW_DEFAULT_RULE;
uint32_t dummy_tables_max = IPFW_TABLES_MAX;
SYSBEGIN(f3)
SYSCTL_NODE(_net_inet_ip, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, one_pass,
CTLFLAG_RW | CTLFLAG_SECURE3, &VNET_NAME(fw_one_pass), 0,
"Only do a single pass through ipfw when using dummynet(4)");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, autoinc_step,
CTLFLAG_RW, &VNET_NAME(autoinc_step), 0,
"Rule number auto-increment step");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, verbose,
CTLFLAG_RW | CTLFLAG_SECURE3, &VNET_NAME(fw_verbose), 0,
"Log matches to ipfw rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, verbose_limit,
CTLFLAG_RW, &VNET_NAME(verbose_limit), 0,
"Set upper limit of matches of ipfw rules logged");
SYSCTL_UINT(_net_inet_ip_fw, OID_AUTO, default_rule, CTLFLAG_RD,
&dummy_def, 0,
"The default/max possible rule number.");
SYSCTL_UINT(_net_inet_ip_fw, OID_AUTO, tables_max, CTLFLAG_RD,
&dummy_tables_max, 0,
"The maximum number of tables.");
SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, default_to_accept, CTLFLAG_RDTUN,
&default_to_accept, 0,
"Make the default rule accept all packets.");
TUNABLE_INT("net.inet.ip.fw.default_to_accept", &default_to_accept);
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, static_count,
CTLFLAG_RD, &VNET_NAME(layer3_chain.n_rules), 0,
"Number of static rules");
#ifdef INET6
SYSCTL_DECL(_net_inet6_ip6);
SYSCTL_NODE(_net_inet6_ip6, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall");
SYSCTL_VNET_INT(_net_inet6_ip6_fw, OID_AUTO, deny_unknown_exthdrs,
CTLFLAG_RW | CTLFLAG_SECURE, &VNET_NAME(fw_deny_unknown_exthdrs), 0,
"Deny packets with unknown IPv6 Extension Headers");
#endif /* INET6 */
SYSEND
#endif /* SYSCTL_NODE */
/*
* Some macros used in the various matching options.
* L3HDR maps an ipv4 pointer into a layer3 header pointer of type T
* Other macros just cast void * into the appropriate type
*/
#define L3HDR(T, ip) ((T *)((u_int32_t *)(ip) + (ip)->ip_hl))
#define TCP(p) ((struct tcphdr *)(p))
#define SCTP(p) ((struct sctphdr *)(p))
#define UDP(p) ((struct udphdr *)(p))
#define ICMP(p) ((struct icmphdr *)(p))
#define ICMP6(p) ((struct icmp6_hdr *)(p))
static __inline int
icmptype_match(struct icmphdr *icmp, ipfw_insn_u32 *cmd)
{
int type = icmp->icmp_type;
return (type <= ICMP_MAXTYPE && (cmd->d[0] & (1<<type)) );
}
#define TT ( (1 << ICMP_ECHO) | (1 << ICMP_ROUTERSOLICIT) | \
(1 << ICMP_TSTAMP) | (1 << ICMP_IREQ) | (1 << ICMP_MASKREQ) )
static int
is_icmp_query(struct icmphdr *icmp)
{
int type = icmp->icmp_type;
return (type <= ICMP_MAXTYPE && (TT & (1<<type)) );
}
#undef TT
/*
* The following checks use two arrays of 8 or 16 bits to store the
* bits that we want set or clear, respectively. They are in the
* low and high half of cmd->arg1 or cmd->d[0].
*
* We scan options and store the bits we find set. We succeed if
*
* (want_set & ~bits) == 0 && (want_clear & ~bits) == want_clear
*
* The code is sometimes optimized not to store additional variables.
*/
static int
flags_match(ipfw_insn *cmd, u_int8_t bits)
{
u_char want_clear;
bits = ~bits;
if ( ((cmd->arg1 & 0xff) & bits) != 0)
return 0; /* some bits we want set were clear */
want_clear = (cmd->arg1 >> 8) & 0xff;
if ( (want_clear & bits) != want_clear)
return 0; /* some bits we want clear were set */
return 1;
}
static int
ipopts_match(struct ip *ip, ipfw_insn *cmd)
{
int optlen, bits = 0;
u_char *cp = (u_char *)(ip + 1);
int x = (ip->ip_hl << 2) - sizeof (struct ip);
for (; x > 0; x -= optlen, cp += optlen) {
int opt = cp[IPOPT_OPTVAL];
if (opt == IPOPT_EOL)
break;
if (opt == IPOPT_NOP)
optlen = 1;
else {
optlen = cp[IPOPT_OLEN];
if (optlen <= 0 || optlen > x)
return 0; /* invalid or truncated */
}
switch (opt) {
default:
break;
case IPOPT_LSRR:
bits |= IP_FW_IPOPT_LSRR;
break;
case IPOPT_SSRR:
bits |= IP_FW_IPOPT_SSRR;
break;
case IPOPT_RR:
bits |= IP_FW_IPOPT_RR;
break;
case IPOPT_TS:
bits |= IP_FW_IPOPT_TS;
break;
}
}
return (flags_match(cmd, bits));
}
static int
tcpopts_match(struct tcphdr *tcp, ipfw_insn *cmd)
{
int optlen, bits = 0;
u_char *cp = (u_char *)(tcp + 1);
int x = (tcp->th_off << 2) - sizeof(struct tcphdr);
for (; x > 0; x -= optlen, cp += optlen) {
int opt = cp[0];
if (opt == TCPOPT_EOL)
break;
if (opt == TCPOPT_NOP)
optlen = 1;
else {
optlen = cp[1];
if (optlen <= 0)
break;
}
switch (opt) {
default:
break;
case TCPOPT_MAXSEG:
bits |= IP_FW_TCPOPT_MSS;
break;
case TCPOPT_WINDOW:
bits |= IP_FW_TCPOPT_WINDOW;
break;
case TCPOPT_SACK_PERMITTED:
case TCPOPT_SACK:
bits |= IP_FW_TCPOPT_SACK;
break;
case TCPOPT_TIMESTAMP:
bits |= IP_FW_TCPOPT_TS;
break;
}
}
return (flags_match(cmd, bits));
}
static int
iface_match(struct ifnet *ifp, ipfw_insn_if *cmd)
{
if (ifp == NULL) /* no iface with this packet, match fails */
return 0;
/* Check by name or by IP address */
if (cmd->name[0] != '\0') { /* match by name */
/* Check name */
if (cmd->p.glob) {
if (fnmatch(cmd->name, ifp->if_xname, 0) == 0)
return(1);
} else {
if (strncmp(ifp->if_xname, cmd->name, IFNAMSIZ) == 0)
return(1);
}
} else {
#ifdef __FreeBSD__ /* and OSX too ? */
struct ifaddr *ia;
if_addr_rlock(ifp);
TAILQ_FOREACH(ia, &ifp->if_addrhead, ifa_link) {
if (ia->ifa_addr->sa_family != AF_INET)
continue;
if (cmd->p.ip.s_addr == ((struct sockaddr_in *)
(ia->ifa_addr))->sin_addr.s_addr) {
if_addr_runlock(ifp);
return(1); /* match */
}
}
if_addr_runlock(ifp);
#endif /* __FreeBSD__ */
}
return(0); /* no match, fail ... */
}
/*
* The verify_path function checks if a route to the src exists and
* if it is reachable via ifp (when provided).
*
* The 'verrevpath' option checks that the interface that an IP packet
* arrives on is the same interface that traffic destined for the
* packet's source address would be routed out of.
* The 'versrcreach' option just checks that the source address is
* reachable via any route (except default) in the routing table.
* These two are a measure to block forged packets. This is also
* commonly known as "anti-spoofing" or Unicast Reverse Path
* Forwarding (Unicast RFP) in Cisco-ese. The name of the knobs
* is purposely reminiscent of the Cisco IOS command,
*
* ip verify unicast reverse-path
* ip verify unicast source reachable-via any
*
* which implements the same functionality. But note that the syntax
* is misleading, and the check may be performed on all IP packets
* whether unicast, multicast, or broadcast.
*/
static int
verify_path(struct in_addr src, struct ifnet *ifp, u_int fib)
{
#ifndef __FreeBSD__
return 0;
#else
struct route ro;
struct sockaddr_in *dst;
bzero(&ro, sizeof(ro));
dst = (struct sockaddr_in *)&(ro.ro_dst);
dst->sin_family = AF_INET;
dst->sin_len = sizeof(*dst);
dst->sin_addr = src;
in_rtalloc_ign(&ro, 0, fib);
if (ro.ro_rt == NULL)
return 0;
/*
* If ifp is provided, check for equality with rtentry.
* We should use rt->rt_ifa->ifa_ifp, instead of rt->rt_ifp,
* in order to pass packets injected back by if_simloop():
* if useloopback == 1 routing entry (via lo0) for our own address
* may exist, so we need to handle routing assymetry.
*/
if (ifp != NULL && ro.ro_rt->rt_ifa->ifa_ifp != ifp) {
RTFREE(ro.ro_rt);
return 0;
}
/* if no ifp provided, check if rtentry is not default route */
if (ifp == NULL &&
satosin(rt_key(ro.ro_rt))->sin_addr.s_addr == INADDR_ANY) {
RTFREE(ro.ro_rt);
return 0;
}
/* or if this is a blackhole/reject route */
if (ifp == NULL && ro.ro_rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
RTFREE(ro.ro_rt);
return 0;
}
/* found valid route */
RTFREE(ro.ro_rt);
return 1;
#endif /* __FreeBSD__ */
}
#ifdef INET6
/*
* ipv6 specific rules here...
*/
static __inline int
icmp6type_match (int type, ipfw_insn_u32 *cmd)
{
return (type <= ICMP6_MAXTYPE && (cmd->d[type/32] & (1<<(type%32)) ) );
}
static int
flow6id_match( int curr_flow, ipfw_insn_u32 *cmd )
{
int i;
for (i=0; i <= cmd->o.arg1; ++i )
if (curr_flow == cmd->d[i] )
return 1;
return 0;
}
/* support for IP6_*_ME opcodes */
static int
search_ip6_addr_net (struct in6_addr * ip6_addr)
{
struct ifnet *mdc;
struct ifaddr *mdc2;
struct in6_ifaddr *fdm;
struct in6_addr copia;
TAILQ_FOREACH(mdc, &V_ifnet, if_link) {
if_addr_rlock(mdc);
TAILQ_FOREACH(mdc2, &mdc->if_addrhead, ifa_link) {
if (mdc2->ifa_addr->sa_family == AF_INET6) {
fdm = (struct in6_ifaddr *)mdc2;
copia = fdm->ia_addr.sin6_addr;
/* need for leaving scope_id in the sock_addr */
in6_clearscope(&copia);
if (IN6_ARE_ADDR_EQUAL(ip6_addr, &copia)) {
if_addr_runlock(mdc);
return 1;
}
}
}
if_addr_runlock(mdc);
}
return 0;
}
static int
verify_path6(struct in6_addr *src, struct ifnet *ifp)
{
struct route_in6 ro;
struct sockaddr_in6 *dst;
bzero(&ro, sizeof(ro));
dst = (struct sockaddr_in6 * )&(ro.ro_dst);
dst->sin6_family = AF_INET6;
dst->sin6_len = sizeof(*dst);
dst->sin6_addr = *src;
/* XXX MRT 0 for ipv6 at this time */
rtalloc_ign((struct route *)&ro, 0);
if (ro.ro_rt == NULL)
return 0;
/*
* if ifp is provided, check for equality with rtentry
* We should use rt->rt_ifa->ifa_ifp, instead of rt->rt_ifp,
* to support the case of sending packets to an address of our own.
* (where the former interface is the first argument of if_simloop()
* (=ifp), the latter is lo0)
*/
if (ifp != NULL && ro.ro_rt->rt_ifa->ifa_ifp != ifp) {
RTFREE(ro.ro_rt);
return 0;
}
/* if no ifp provided, check if rtentry is not default route */
if (ifp == NULL &&
IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(ro.ro_rt))->sin6_addr)) {
RTFREE(ro.ro_rt);
return 0;
}
/* or if this is a blackhole/reject route */
if (ifp == NULL && ro.ro_rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
RTFREE(ro.ro_rt);
return 0;
}
/* found valid route */
RTFREE(ro.ro_rt);
return 1;
}
static int
is_icmp6_query(int icmp6_type)
{
if ((icmp6_type <= ICMP6_MAXTYPE) &&
(icmp6_type == ICMP6_ECHO_REQUEST ||
icmp6_type == ICMP6_MEMBERSHIP_QUERY ||
icmp6_type == ICMP6_WRUREQUEST ||
icmp6_type == ICMP6_FQDN_QUERY ||
icmp6_type == ICMP6_NI_QUERY))
return (1);
return (0);
}
static void
send_reject6(struct ip_fw_args *args, int code, u_int hlen, struct ip6_hdr *ip6)
{
struct mbuf *m;
m = args->m;
if (code == ICMP6_UNREACH_RST && args->f_id.proto == IPPROTO_TCP) {
struct tcphdr *tcp;
tcp = (struct tcphdr *)((char *)ip6 + hlen);
if ((tcp->th_flags & TH_RST) == 0) {
struct mbuf *m0;
m0 = ipfw_send_pkt(args->m, &(args->f_id),
ntohl(tcp->th_seq), ntohl(tcp->th_ack),
tcp->th_flags | TH_RST);
if (m0 != NULL)
ip6_output(m0, NULL, NULL, 0, NULL, NULL,
NULL);
}
FREE_PKT(m);
} else if (code != ICMP6_UNREACH_RST) { /* Send an ICMPv6 unreach. */
#if 0
/*
* Unlike above, the mbufs need to line up with the ip6 hdr,
* as the contents are read. We need to m_adj() the
* needed amount.
* The mbuf will however be thrown away so we can adjust it.
* Remember we did an m_pullup on it already so we
* can make some assumptions about contiguousness.
*/
if (args->L3offset)
m_adj(m, args->L3offset);
#endif
icmp6_error(m, ICMP6_DST_UNREACH, code, 0);
} else
FREE_PKT(m);
args->m = NULL;
}
#endif /* INET6 */
/*
* sends a reject message, consuming the mbuf passed as an argument.
*/
static void
send_reject(struct ip_fw_args *args, int code, int iplen, struct ip *ip)
{
#if 0
/* XXX When ip is not guaranteed to be at mtod() we will
* need to account for this */
* The mbuf will however be thrown away so we can adjust it.
* Remember we did an m_pullup on it already so we
* can make some assumptions about contiguousness.
*/
if (args->L3offset)
m_adj(m, args->L3offset);
#endif
if (code != ICMP_REJECT_RST) { /* Send an ICMP unreach */
/* We need the IP header in host order for icmp_error(). */
SET_HOST_IPLEN(ip);
icmp_error(args->m, ICMP_UNREACH, code, 0L, 0);
} else if (args->f_id.proto == IPPROTO_TCP) {
struct tcphdr *const tcp =
L3HDR(struct tcphdr, mtod(args->m, struct ip *));
if ( (tcp->th_flags & TH_RST) == 0) {
struct mbuf *m;
m = ipfw_send_pkt(args->m, &(args->f_id),
ntohl(tcp->th_seq), ntohl(tcp->th_ack),
tcp->th_flags | TH_RST);
if (m != NULL)
ip_output(m, NULL, NULL, 0, NULL, NULL);
}
FREE_PKT(args->m);
} else
FREE_PKT(args->m);
args->m = NULL;
}
/*
* Support for uid/gid/jail lookup. These tests are expensive
* (because we may need to look into the list of active sockets)
* so we cache the results. ugid_lookupp is 0 if we have not
* yet done a lookup, 1 if we succeeded, and -1 if we tried
* and failed. The function always returns the match value.
* We could actually spare the variable and use *uc, setting
* it to '(void *)check_uidgid if we have no info, NULL if
* we tried and failed, or any other value if successful.
*/
static int
check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
struct in_addr dst_ip, u_int16_t dst_port, struct in_addr src_ip,
u_int16_t src_port, int *ugid_lookupp,
struct ucred **uc, struct inpcb *inp)
{
#ifndef __FreeBSD__
return cred_check(insn, proto, oif,
dst_ip, dst_port, src_ip, src_port,
(struct bsd_ucred *)uc, ugid_lookupp, ((struct mbuf *)inp)->m_skb);
#else /* FreeBSD */
struct inpcbinfo *pi;
int wildcard;
struct inpcb *pcb;
int match;
/*
* Check to see if the UDP or TCP stack supplied us with
* the PCB. If so, rather then holding a lock and looking
* up the PCB, we can use the one that was supplied.
*/
if (inp && *ugid_lookupp == 0) {
INP_LOCK_ASSERT(inp);
if (inp->inp_socket != NULL) {
*uc = crhold(inp->inp_cred);
*ugid_lookupp = 1;
} else
*ugid_lookupp = -1;
}
/*
* If we have already been here and the packet has no
* PCB entry associated with it, then we can safely
* assume that this is a no match.
*/
if (*ugid_lookupp == -1)
return (0);
if (proto == IPPROTO_TCP) {
wildcard = 0;
pi = &V_tcbinfo;
} else if (proto == IPPROTO_UDP) {
wildcard = INPLOOKUP_WILDCARD;
pi = &V_udbinfo;
} else
return 0;
match = 0;
if (*ugid_lookupp == 0) {
INP_INFO_RLOCK(pi);
pcb = (oif) ?
in_pcblookup_hash(pi,
dst_ip, htons(dst_port),
src_ip, htons(src_port),
wildcard, oif) :
in_pcblookup_hash(pi,
src_ip, htons(src_port),
dst_ip, htons(dst_port),
wildcard, NULL);
if (pcb != NULL) {
*uc = crhold(pcb->inp_cred);
*ugid_lookupp = 1;
}
INP_INFO_RUNLOCK(pi);
if (*ugid_lookupp == 0) {
/*
* We tried and failed, set the variable to -1
* so we will not try again on this packet.
*/
*ugid_lookupp = -1;
return (0);
}
}
if (insn->o.opcode == O_UID)
match = ((*uc)->cr_uid == (uid_t)insn->d[0]);
else if (insn->o.opcode == O_GID)
match = groupmember((gid_t)insn->d[0], *uc);
else if (insn->o.opcode == O_JAIL)
match = ((*uc)->cr_prison->pr_id == (int)insn->d[0]);
return match;
#endif /* __FreeBSD__ */
}
/*
* Helper function to set args with info on the rule after the matching
* one. slot is precise, whereas we guess rule_id as they are
* assigned sequentially.
*/
static inline void
set_match(struct ip_fw_args *args, int slot,
struct ip_fw_chain *chain)
{
args->rule.chain_id = chain->id;
args->rule.slot = slot + 1; /* we use 0 as a marker */
args->rule.rule_id = 1 + chain->map[slot]->id;
args->rule.rulenum = chain->map[slot]->rulenum;
}
/*
* The main check routine for the firewall.
*
* All arguments are in args so we can modify them and return them
* back to the caller.
*
* Parameters:
*
* args->m (in/out) The packet; we set to NULL when/if we nuke it.
* Starts with the IP header.
* args->eh (in) Mac header if present, NULL for layer3 packet.
* args->L3offset Number of bytes bypassed if we came from L2.
* e.g. often sizeof(eh) ** NOTYET **
* args->oif Outgoing interface, NULL if packet is incoming.
* The incoming interface is in the mbuf. (in)
* args->divert_rule (in/out)
* Skip up to the first rule past this rule number;
* upon return, non-zero port number for divert or tee.
*
* args->rule Pointer to the last matching rule (in/out)
* args->next_hop Socket we are forwarding to (out).
* args->f_id Addresses grabbed from the packet (out)
* args->rule.info a cookie depending on rule action
*
* Return value:
*
* IP_FW_PASS the packet must be accepted
* IP_FW_DENY the packet must be dropped
* IP_FW_DIVERT divert packet, port in m_tag
* IP_FW_TEE tee packet, port in m_tag
* IP_FW_DUMMYNET to dummynet, pipe in args->cookie
* IP_FW_NETGRAPH into netgraph, cookie args->cookie
* args->rule contains the matching rule,
* args->rule.info has additional information.
*
*/
int
ipfw_chk(struct ip_fw_args *args)
{
/*
* Local variables holding state while processing a packet:
*
* IMPORTANT NOTE: to speed up the processing of rules, there
* are some assumption on the values of the variables, which
* are documented here. Should you change them, please check
* the implementation of the various instructions to make sure
* that they still work.
*
* args->eh The MAC header. It is non-null for a layer2
* packet, it is NULL for a layer-3 packet.
* **notyet**
* args->L3offset Offset in the packet to the L3 (IP or equiv.) header.
*
* m | args->m Pointer to the mbuf, as received from the caller.
* It may change if ipfw_chk() does an m_pullup, or if it
* consumes the packet because it calls send_reject().
* XXX This has to change, so that ipfw_chk() never modifies
* or consumes the buffer.
* ip is the beginning of the ip(4 or 6) header.
* Calculated by adding the L3offset to the start of data.
* (Until we start using L3offset, the packet is
* supposed to start with the ip header).
*/
struct mbuf *m = args->m;
struct ip *ip = mtod(m, struct ip *);
/*
* For rules which contain uid/gid or jail constraints, cache
* a copy of the users credentials after the pcb lookup has been
* executed. This will speed up the processing of rules with
* these types of constraints, as well as decrease contention
* on pcb related locks.
*/
#ifndef __FreeBSD__
struct bsd_ucred ucred_cache;
#else
struct ucred *ucred_cache = NULL;
#endif
int ucred_lookup = 0;
/*
* oif | args->oif If NULL, ipfw_chk has been called on the
* inbound path (ether_input, ip_input).
* If non-NULL, ipfw_chk has been called on the outbound path
* (ether_output, ip_output).
*/
struct ifnet *oif = args->oif;
int f_pos = 0; /* index of current rule in the array */
int retval = 0;
/*
* hlen The length of the IP header.
*/
u_int hlen = 0; /* hlen >0 means we have an IP pkt */
/*
* offset The offset of a fragment. offset != 0 means that
* we have a fragment at this offset of an IPv4 packet.
* offset == 0 means that (if this is an IPv4 packet)
* this is the first or only fragment.
* For IPv6 offset == 0 means there is no Fragment Header.
* If offset != 0 for IPv6 always use correct mask to
* get the correct offset because we add IP6F_MORE_FRAG
* to be able to dectect the first fragment which would
* otherwise have offset = 0.
*/
u_short offset = 0;
/*
* Local copies of addresses. They are only valid if we have
* an IP packet.
*
* proto The protocol. Set to 0 for non-ip packets,
* or to the protocol read from the packet otherwise.
* proto != 0 means that we have an IPv4 packet.
*
* src_port, dst_port port numbers, in HOST format. Only
* valid for TCP and UDP packets.
*
* src_ip, dst_ip ip addresses, in NETWORK format.
* Only valid for IPv4 packets.
*/
uint8_t proto;
uint16_t src_port = 0, dst_port = 0; /* NOTE: host format */
struct in_addr src_ip, dst_ip; /* NOTE: network format */
uint16_t iplen=0;
int pktlen;
uint16_t etype = 0; /* Host order stored ether type */
/*
* dyn_dir = MATCH_UNKNOWN when rules unchecked,
* MATCH_NONE when checked and not matched (q = NULL),
* MATCH_FORWARD or MATCH_REVERSE otherwise (q != NULL)
*/
int dyn_dir = MATCH_UNKNOWN;
ipfw_dyn_rule *q = NULL;
struct ip_fw_chain *chain = &V_layer3_chain;
/*
* We store in ulp a pointer to the upper layer protocol header.
* In the ipv4 case this is easy to determine from the header,
* but for ipv6 we might have some additional headers in the middle.
* ulp is NULL if not found.
*/
void *ulp = NULL; /* upper layer protocol pointer. */
/* XXX ipv6 variables */
int is_ipv6 = 0;
uint8_t icmp6_type = 0;
uint16_t ext_hd = 0; /* bits vector for extension header filtering */
/* end of ipv6 variables */
int is_ipv4 = 0;
int done = 0; /* flag to exit the outer loop */
if (m->m_flags & M_SKIP_FIREWALL || (! V_ipfw_vnet_ready))
return (IP_FW_PASS); /* accept */
dst_ip.s_addr = 0; /* make sure it is initialized */
src_ip.s_addr = 0; /* make sure it is initialized */
pktlen = m->m_pkthdr.len;
args->f_id.fib = M_GETFIB(m); /* note mbuf not altered) */
proto = args->f_id.proto = 0; /* mark f_id invalid */
/* XXX 0 is a valid proto: IP/IPv6 Hop-by-Hop Option */
/*
* PULLUP_TO(len, p, T) makes sure that len + sizeof(T) is contiguous,
* then it sets p to point at the offset "len" in the mbuf. WARNING: the
* pointer might become stale after other pullups (but we never use it
* this way).
*/
#define PULLUP_TO(_len, p, T) \
do { \
int x = (_len) + sizeof(T); \
if ((m)->m_len < x) { \
args->m = m = m_pullup(m, x); \
if (m == NULL) \
goto pullup_failed; \
} \
p = (mtod(m, char *) + (_len)); \
} while (0)
/*
* if we have an ether header,
*/
if (args->eh)
etype = ntohs(args->eh->ether_type);
/* Identify IP packets and fill up variables. */
if (pktlen >= sizeof(struct ip6_hdr) &&
(args->eh == NULL || etype == ETHERTYPE_IPV6) && ip->ip_v == 6) {
struct ip6_hdr *ip6 = (struct ip6_hdr *)ip;
is_ipv6 = 1;
args->f_id.addr_type = 6;
hlen = sizeof(struct ip6_hdr);
proto = ip6->ip6_nxt;
/* Search extension headers to find upper layer protocols */
while (ulp == NULL) {
switch (proto) {
case IPPROTO_ICMPV6:
PULLUP_TO(hlen, ulp, struct icmp6_hdr);
icmp6_type = ICMP6(ulp)->icmp6_type;
break;
case IPPROTO_TCP:
PULLUP_TO(hlen, ulp, struct tcphdr);
dst_port = TCP(ulp)->th_dport;
src_port = TCP(ulp)->th_sport;
/* save flags for dynamic rules */
args->f_id._flags = TCP(ulp)->th_flags;
break;
case IPPROTO_SCTP:
PULLUP_TO(hlen, ulp, struct sctphdr);
src_port = SCTP(ulp)->src_port;
dst_port = SCTP(ulp)->dest_port;
break;
case IPPROTO_UDP:
PULLUP_TO(hlen, ulp, struct udphdr);
dst_port = UDP(ulp)->uh_dport;
src_port = UDP(ulp)->uh_sport;
break;
case IPPROTO_HOPOPTS: /* RFC 2460 */
PULLUP_TO(hlen, ulp, struct ip6_hbh);
ext_hd |= EXT_HOPOPTS;
hlen += (((struct ip6_hbh *)ulp)->ip6h_len + 1) << 3;
proto = ((struct ip6_hbh *)ulp)->ip6h_nxt;
ulp = NULL;
break;
case IPPROTO_ROUTING: /* RFC 2460 */
PULLUP_TO(hlen, ulp, struct ip6_rthdr);
switch (((struct ip6_rthdr *)ulp)->ip6r_type) {
case 0:
ext_hd |= EXT_RTHDR0;
break;
case 2:
ext_hd |= EXT_RTHDR2;
break;
default:
printf("IPFW2: IPV6 - Unknown Routing "
"Header type(%d)\n",
((struct ip6_rthdr *)ulp)->ip6r_type);
if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
break;
}
ext_hd |= EXT_ROUTING;
hlen += (((struct ip6_rthdr *)ulp)->ip6r_len + 1) << 3;
proto = ((struct ip6_rthdr *)ulp)->ip6r_nxt;
ulp = NULL;
break;
case IPPROTO_FRAGMENT: /* RFC 2460 */
PULLUP_TO(hlen, ulp, struct ip6_frag);
ext_hd |= EXT_FRAGMENT;
hlen += sizeof (struct ip6_frag);
proto = ((struct ip6_frag *)ulp)->ip6f_nxt;
offset = ((struct ip6_frag *)ulp)->ip6f_offlg &
IP6F_OFF_MASK;
/* Add IP6F_MORE_FRAG for offset of first
* fragment to be != 0. */
offset |= ((struct ip6_frag *)ulp)->ip6f_offlg &
IP6F_MORE_FRAG;
if (offset == 0) {
printf("IPFW2: IPV6 - Invalid Fragment "
"Header\n");
if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
break;
}
args->f_id.extra =
ntohl(((struct ip6_frag *)ulp)->ip6f_ident);
ulp = NULL;
break;
case IPPROTO_DSTOPTS: /* RFC 2460 */
PULLUP_TO(hlen, ulp, struct ip6_hbh);
ext_hd |= EXT_DSTOPTS;
hlen += (((struct ip6_hbh *)ulp)->ip6h_len + 1) << 3;
proto = ((struct ip6_hbh *)ulp)->ip6h_nxt;
ulp = NULL;
break;
case IPPROTO_AH: /* RFC 2402 */
PULLUP_TO(hlen, ulp, struct ip6_ext);
ext_hd |= EXT_AH;
hlen += (((struct ip6_ext *)ulp)->ip6e_len + 2) << 2;
proto = ((struct ip6_ext *)ulp)->ip6e_nxt;
ulp = NULL;
break;
case IPPROTO_ESP: /* RFC 2406 */
PULLUP_TO(hlen, ulp, uint32_t); /* SPI, Seq# */
/* Anything past Seq# is variable length and
* data past this ext. header is encrypted. */
ext_hd |= EXT_ESP;
break;
case IPPROTO_NONE: /* RFC 2460 */
/*
* Packet ends here, and IPv6 header has
* already been pulled up. If ip6e_len!=0
* then octets must be ignored.
*/
ulp = ip; /* non-NULL to get out of loop. */
break;
case IPPROTO_OSPFIGP:
/* XXX OSPF header check? */
PULLUP_TO(hlen, ulp, struct ip6_ext);
break;
case IPPROTO_PIM:
/* XXX PIM header check? */
PULLUP_TO(hlen, ulp, struct pim);
break;
case IPPROTO_CARP:
PULLUP_TO(hlen, ulp, struct carp_header);
if (((struct carp_header *)ulp)->carp_version !=
CARP_VERSION)
return (IP_FW_DENY);
if (((struct carp_header *)ulp)->carp_type !=
CARP_ADVERTISEMENT)
return (IP_FW_DENY);
break;
case IPPROTO_IPV6: /* RFC 2893 */
PULLUP_TO(hlen, ulp, struct ip6_hdr);
break;
case IPPROTO_IPV4: /* RFC 2893 */
PULLUP_TO(hlen, ulp, struct ip);
break;
default:
printf("IPFW2: IPV6 - Unknown Extension "
"Header(%d), ext_hd=%x\n", proto, ext_hd);
if (V_fw_deny_unknown_exthdrs)
return (IP_FW_DENY);
PULLUP_TO(hlen, ulp, struct ip6_ext);
break;
} /*switch */
}
ip = mtod(m, struct ip *);
ip6 = (struct ip6_hdr *)ip;
args->f_id.src_ip6 = ip6->ip6_src;
args->f_id.dst_ip6 = ip6->ip6_dst;
args->f_id.src_ip = 0;
args->f_id.dst_ip = 0;
args->f_id.flow_id6 = ntohl(ip6->ip6_flow);
} else if (pktlen >= sizeof(struct ip) &&
(args->eh == NULL || etype == ETHERTYPE_IP) && ip->ip_v == 4) {
is_ipv4 = 1;
hlen = ip->ip_hl << 2;
args->f_id.addr_type = 4;
/*
* Collect parameters into local variables for faster matching.
*/
proto = ip->ip_p;
src_ip = ip->ip_src;
dst_ip = ip->ip_dst;
offset = ntohs(ip->ip_off) & IP_OFFMASK;
iplen = ntohs(ip->ip_len);
pktlen = iplen < pktlen ? iplen : pktlen;
if (offset == 0) {
switch (proto) {
case IPPROTO_TCP:
PULLUP_TO(hlen, ulp, struct tcphdr);
dst_port = TCP(ulp)->th_dport;
src_port = TCP(ulp)->th_sport;
/* save flags for dynamic rules */
args->f_id._flags = TCP(ulp)->th_flags;
break;
case IPPROTO_UDP:
PULLUP_TO(hlen, ulp, struct udphdr);
dst_port = UDP(ulp)->uh_dport;
src_port = UDP(ulp)->uh_sport;
break;
case IPPROTO_ICMP:
PULLUP_TO(hlen, ulp, struct icmphdr);
//args->f_id.flags = ICMP(ulp)->icmp_type;
break;
default:
break;
}
}
ip = mtod(m, struct ip *);
args->f_id.src_ip = ntohl(src_ip.s_addr);
args->f_id.dst_ip = ntohl(dst_ip.s_addr);
}
#undef PULLUP_TO
if (proto) { /* we may have port numbers, store them */
args->f_id.proto = proto;
args->f_id.src_port = src_port = ntohs(src_port);
args->f_id.dst_port = dst_port = ntohs(dst_port);
}
IPFW_RLOCK(chain);
if (! V_ipfw_vnet_ready) { /* shutting down, leave NOW. */
IPFW_RUNLOCK(chain);
return (IP_FW_PASS); /* accept */
}
if (args->rule.slot) {
/*
* Packet has already been tagged as a result of a previous
* match on rule args->rule aka args->rule_id (PIPE, QUEUE,
* REASS, NETGRAPH, DIVERT/TEE...)
* Validate the slot and continue from the next one
* if still present, otherwise do a lookup.
*/
f_pos = (args->rule.chain_id == chain->id) ?
args->rule.slot :
ipfw_find_rule(chain, args->rule.rulenum,
args->rule.rule_id);
} else {
f_pos = 0;
}
/*
* Now scan the rules, and parse microinstructions for each rule.
* We have two nested loops and an inner switch. Sometimes we
* need to break out of one or both loops, or re-enter one of
* the loops with updated variables. Loop variables are:
*
* f_pos (outer loop) points to the current rule.
* On output it points to the matching rule.
* done (outer loop) is used as a flag to break the loop.
* l (inner loop) residual length of current rule.
* cmd points to the current microinstruction.
*
* We break the inner loop by setting l=0 and possibly
* cmdlen=0 if we don't want to advance cmd.
* We break the outer loop by setting done=1
* We can restart the inner loop by setting l>0 and f_pos, f, cmd
* as needed.
*/
for (; f_pos < chain->n_rules; f_pos++) {
ipfw_insn *cmd;
uint32_t tablearg = 0;
int l, cmdlen, skip_or; /* skip rest of OR block */
struct ip_fw *f;
f = chain->map[f_pos];
if (V_set_disable & (1 << f->set) )
continue;
skip_or = 0;
for (l = f->cmd_len, cmd = f->cmd ; l > 0 ;
l -= cmdlen, cmd += cmdlen) {
int match;
/*
* check_body is a jump target used when we find a
* CHECK_STATE, and need to jump to the body of
* the target rule.
*/
/* check_body: */
cmdlen = F_LEN(cmd);
/*
* An OR block (insn_1 || .. || insn_n) has the
* F_OR bit set in all but the last instruction.
* The first match will set "skip_or", and cause
* the following instructions to be skipped until
* past the one with the F_OR bit clear.
*/
if (skip_or) { /* skip this instruction */
if ((cmd->len & F_OR) == 0)
skip_or = 0; /* next one is good */
continue;
}
match = 0; /* set to 1 if we succeed */
switch (cmd->opcode) {
/*
* The first set of opcodes compares the packet's
* fields with some pattern, setting 'match' if a
* match is found. At the end of the loop there is
* logic to deal with F_NOT and F_OR flags associated
* with the opcode.
*/
case O_NOP:
match = 1;
break;
case O_FORWARD_MAC:
printf("ipfw: opcode %d unimplemented\n",
cmd->opcode);
break;
case O_GID:
case O_UID:
case O_JAIL:
/*
* We only check offset == 0 && proto != 0,
* as this ensures that we have a
* packet with the ports info.
*/
if (offset!=0)
break;
if (is_ipv6) /* XXX to be fixed later */
break;
if (proto == IPPROTO_TCP ||
proto == IPPROTO_UDP)
match = check_uidgid(
(ipfw_insn_u32 *)cmd,
proto, oif,
dst_ip, dst_port,
src_ip, src_port, &ucred_lookup,
#ifdef __FreeBSD__
&ucred_cache, args->inp);
#else
(void *)&ucred_cache,
(struct inpcb *)args->m);
#endif
break;
case O_RECV:
match = iface_match(m->m_pkthdr.rcvif,
(ipfw_insn_if *)cmd);
break;
case O_XMIT:
match = iface_match(oif, (ipfw_insn_if *)cmd);
break;
case O_VIA:
match = iface_match(oif ? oif :
m->m_pkthdr.rcvif, (ipfw_insn_if *)cmd);
break;
case O_MACADDR2:
if (args->eh != NULL) { /* have MAC header */
u_int32_t *want = (u_int32_t *)
((ipfw_insn_mac *)cmd)->addr;
u_int32_t *mask = (u_int32_t *)
((ipfw_insn_mac *)cmd)->mask;
u_int32_t *hdr = (u_int32_t *)args->eh;
match =
( want[0] == (hdr[0] & mask[0]) &&
want[1] == (hdr[1] & mask[1]) &&
want[2] == (hdr[2] & mask[2]) );
}
break;
case O_MAC_TYPE:
if (args->eh != NULL) {
u_int16_t *p =
((ipfw_insn_u16 *)cmd)->ports;
int i;
for (i = cmdlen - 1; !match && i>0;
i--, p += 2)
match = (etype >= p[0] &&
etype <= p[1]);
}
break;
case O_FRAG:
match = (offset != 0);
break;
case O_IN: /* "out" is "not in" */
match = (oif == NULL);
break;
case O_LAYER2:
match = (args->eh != NULL);
break;
case O_DIVERTED:
{
/* For diverted packets, args->rule.info
* contains the divert port (in host format)
* reason and direction.
*/
uint32_t i = args->rule.info;
match = (i&IPFW_IS_MASK) == IPFW_IS_DIVERT &&
cmd->arg1 & ((i & IPFW_INFO_IN) ? 1 : 2);
}
break;
case O_PROTO:
/*
* We do not allow an arg of 0 so the
* check of "proto" only suffices.
*/
match = (proto == cmd->arg1);
break;
case O_IP_SRC:
match = is_ipv4 &&
(((ipfw_insn_ip *)cmd)->addr.s_addr ==
src_ip.s_addr);
break;
case O_IP_SRC_LOOKUP:
case O_IP_DST_LOOKUP:
if (is_ipv4) {
uint32_t key =
(cmd->opcode == O_IP_DST_LOOKUP) ?
dst_ip.s_addr : src_ip.s_addr;
uint32_t v = 0;
if (cmdlen > F_INSN_SIZE(ipfw_insn_u32)) {
/* generic lookup. The key must be
* in 32bit big-endian format.
*/
v = ((ipfw_insn_u32 *)cmd)->d[1];
if (v == 0)
key = dst_ip.s_addr;
else if (v == 1)
key = src_ip.s_addr;
else if (v == 6) /* dscp */
key = (ip->ip_tos >> 2) & 0x3f;
else if (offset != 0)
break;
else if (proto != IPPROTO_TCP &&
proto != IPPROTO_UDP)
break;
else if (v == 2)
key = htonl(dst_port);
else if (v == 3)
key = htonl(src_port);
else if (v == 4 || v == 5) {
check_uidgid(
(ipfw_insn_u32 *)cmd,
proto, oif,
dst_ip, dst_port,
src_ip, src_port, &ucred_lookup,
#ifdef __FreeBSD__
&ucred_cache, args->inp);
if (v == 4 /* O_UID */)
key = ucred_cache->cr_uid;
else if (v == 5 /* O_JAIL */)
key = ucred_cache->cr_prison->pr_id;
#else /* !__FreeBSD__ */
(void *)&ucred_cache,
(struct inpcb *)args->m);
if (v ==4 /* O_UID */)
key = ucred_cache.uid;
else if (v == 5 /* O_JAIL */)
key = ucred_cache.xid;
#endif /* !__FreeBSD__ */
key = htonl(key);
} else
break;
}
match = ipfw_lookup_table(chain,
cmd->arg1, key, &v);
if (!match)
break;
if (cmdlen == F_INSN_SIZE(ipfw_insn_u32))
match =
((ipfw_insn_u32 *)cmd)->d[0] == v;
else
tablearg = v;
}
break;
case O_IP_SRC_MASK:
case O_IP_DST_MASK:
if (is_ipv4) {
uint32_t a =
(cmd->opcode == O_IP_DST_MASK) ?
dst_ip.s_addr : src_ip.s_addr;
uint32_t *p = ((ipfw_insn_u32 *)cmd)->d;
int i = cmdlen-1;
for (; !match && i>0; i-= 2, p+= 2)
match = (p[0] == (a & p[1]));
}
break;
case O_IP_SRC_ME:
if (is_ipv4) {
struct ifnet *tif;
INADDR_TO_IFP(src_ip, tif);
match = (tif != NULL);
break;
}
#ifdef INET6
/* FALLTHROUGH */
case O_IP6_SRC_ME:
match= is_ipv6 && search_ip6_addr_net(&args->f_id.src_ip6);
#endif
break;
case O_IP_DST_SET:
case O_IP_SRC_SET:
if (is_ipv4) {
u_int32_t *d = (u_int32_t *)(cmd+1);
u_int32_t addr =
cmd->opcode == O_IP_DST_SET ?
args->f_id.dst_ip :
args->f_id.src_ip;
if (addr < d[0])
break;
addr -= d[0]; /* subtract base */
match = (addr < cmd->arg1) &&
( d[ 1 + (addr>>5)] &
(1<<(addr & 0x1f)) );
}
break;
case O_IP_DST:
match = is_ipv4 &&
(((ipfw_insn_ip *)cmd)->addr.s_addr ==
dst_ip.s_addr);
break;
case O_IP_DST_ME:
if (is_ipv4) {
struct ifnet *tif;
INADDR_TO_IFP(dst_ip, tif);
match = (tif != NULL);
break;
}
#ifdef INET6
/* FALLTHROUGH */
case O_IP6_DST_ME:
match= is_ipv6 && search_ip6_addr_net(&args->f_id.dst_ip6);
#endif
break;
case O_IP_SRCPORT:
case O_IP_DSTPORT:
/*
* offset == 0 && proto != 0 is enough
* to guarantee that we have a
* packet with port info.
*/
if ((proto==IPPROTO_UDP || proto==IPPROTO_TCP)
&& offset == 0) {
u_int16_t x =
(cmd->opcode == O_IP_SRCPORT) ?
src_port : dst_port ;
u_int16_t *p =
((ipfw_insn_u16 *)cmd)->ports;
int i;
for (i = cmdlen - 1; !match && i>0;
i--, p += 2)
match = (x>=p[0] && x<=p[1]);
}
break;
case O_ICMPTYPE:
match = (offset == 0 && proto==IPPROTO_ICMP &&
icmptype_match(ICMP(ulp), (ipfw_insn_u32 *)cmd) );
break;
#ifdef INET6
case O_ICMP6TYPE:
match = is_ipv6 && offset == 0 &&
proto==IPPROTO_ICMPV6 &&
icmp6type_match(
ICMP6(ulp)->icmp6_type,
(ipfw_insn_u32 *)cmd);
break;
#endif /* INET6 */
case O_IPOPT:
match = (is_ipv4 &&
ipopts_match(ip, cmd) );
break;
case O_IPVER:
match = (is_ipv4 &&
cmd->arg1 == ip->ip_v);
break;
case O_IPID:
case O_IPLEN:
case O_IPTTL:
if (is_ipv4) { /* only for IP packets */
uint16_t x;
uint16_t *p;
int i;
if (cmd->opcode == O_IPLEN)
x = iplen;
else if (cmd->opcode == O_IPTTL)
x = ip->ip_ttl;
else /* must be IPID */
x = ntohs(ip->ip_id);
if (cmdlen == 1) {
match = (cmd->arg1 == x);
break;
}
/* otherwise we have ranges */
p = ((ipfw_insn_u16 *)cmd)->ports;
i = cmdlen - 1;
for (; !match && i>0; i--, p += 2)
match = (x >= p[0] && x <= p[1]);
}
break;
case O_IPPRECEDENCE:
match = (is_ipv4 &&
(cmd->arg1 == (ip->ip_tos & 0xe0)) );
break;
case O_IPTOS:
match = (is_ipv4 &&
flags_match(cmd, ip->ip_tos));
break;
case O_TCPDATALEN:
if (proto == IPPROTO_TCP && offset == 0) {
struct tcphdr *tcp;
uint16_t x;
uint16_t *p;
int i;
tcp = TCP(ulp);
x = iplen -
((ip->ip_hl + tcp->th_off) << 2);
if (cmdlen == 1) {
match = (cmd->arg1 == x);
break;
}
/* otherwise we have ranges */
p = ((ipfw_insn_u16 *)cmd)->ports;
i = cmdlen - 1;
for (; !match && i>0; i--, p += 2)
match = (x >= p[0] && x <= p[1]);
}
break;
case O_TCPFLAGS:
match = (proto == IPPROTO_TCP && offset == 0 &&
flags_match(cmd, TCP(ulp)->th_flags));
break;
case O_TCPOPTS:
match = (proto == IPPROTO_TCP && offset == 0 &&
tcpopts_match(TCP(ulp), cmd));
break;
case O_TCPSEQ:
match = (proto == IPPROTO_TCP && offset == 0 &&
((ipfw_insn_u32 *)cmd)->d[0] ==
TCP(ulp)->th_seq);
break;
case O_TCPACK:
match = (proto == IPPROTO_TCP && offset == 0 &&
((ipfw_insn_u32 *)cmd)->d[0] ==
TCP(ulp)->th_ack);
break;
case O_TCPWIN:
match = (proto == IPPROTO_TCP && offset == 0 &&
cmd->arg1 == TCP(ulp)->th_win);
break;
case O_ESTAB:
/* reject packets which have SYN only */
/* XXX should i also check for TH_ACK ? */
match = (proto == IPPROTO_TCP && offset == 0 &&
(TCP(ulp)->th_flags &
(TH_RST | TH_ACK | TH_SYN)) != TH_SYN);
break;
case O_ALTQ: {
struct pf_mtag *at;
ipfw_insn_altq *altq = (ipfw_insn_altq *)cmd;
match = 1;
at = pf_find_mtag(m);
if (at != NULL && at->qid != 0)
break;
at = pf_get_mtag(m);
if (at == NULL) {
/*
* Let the packet fall back to the
* default ALTQ.
*/
break;
}
at->qid = altq->qid;
if (is_ipv4)
at->af = AF_INET;
else
at->af = AF_LINK;
at->hdr = ip;
break;
}
case O_LOG:
ipfw_log(f, hlen, args, m,
oif, offset, tablearg, ip);
match = 1;
break;
case O_PROB:
match = (random()<((ipfw_insn_u32 *)cmd)->d[0]);
break;
case O_VERREVPATH:
/* Outgoing packets automatically pass/match */
match = ((oif != NULL) ||
(m->m_pkthdr.rcvif == NULL) ||
(
#ifdef INET6
is_ipv6 ?
verify_path6(&(args->f_id.src_ip6),
m->m_pkthdr.rcvif) :
#endif
verify_path(src_ip, m->m_pkthdr.rcvif,
args->f_id.fib)));
break;
case O_VERSRCREACH:
/* Outgoing packets automatically pass/match */
match = (hlen > 0 && ((oif != NULL) ||
#ifdef INET6
is_ipv6 ?
verify_path6(&(args->f_id.src_ip6),
NULL) :
#endif
verify_path(src_ip, NULL, args->f_id.fib)));
break;
case O_ANTISPOOF:
/* Outgoing packets automatically pass/match */
if (oif == NULL && hlen > 0 &&
( (is_ipv4 && in_localaddr(src_ip))
#ifdef INET6
|| (is_ipv6 &&
in6_localaddr(&(args->f_id.src_ip6)))
#endif
))
match =
#ifdef INET6
is_ipv6 ? verify_path6(
&(args->f_id.src_ip6),
m->m_pkthdr.rcvif) :
#endif
verify_path(src_ip,
m->m_pkthdr.rcvif,
args->f_id.fib);
else
match = 1;
break;
case O_IPSEC:
#ifdef IPSEC
match = (m_tag_find(m,
PACKET_TAG_IPSEC_IN_DONE, NULL) != NULL);
#endif
/* otherwise no match */
break;
#ifdef INET6
case O_IP6_SRC:
match = is_ipv6 &&
IN6_ARE_ADDR_EQUAL(&args->f_id.src_ip6,
&((ipfw_insn_ip6 *)cmd)->addr6);
break;
case O_IP6_DST:
match = is_ipv6 &&
IN6_ARE_ADDR_EQUAL(&args->f_id.dst_ip6,
&((ipfw_insn_ip6 *)cmd)->addr6);
break;
case O_IP6_SRC_MASK:
case O_IP6_DST_MASK:
if (is_ipv6) {
int i = cmdlen - 1;
struct in6_addr p;
struct in6_addr *d =
&((ipfw_insn_ip6 *)cmd)->addr6;
for (; !match && i > 0; d += 2,
i -= F_INSN_SIZE(struct in6_addr)
* 2) {
p = (cmd->opcode ==
O_IP6_SRC_MASK) ?
args->f_id.src_ip6:
args->f_id.dst_ip6;
APPLY_MASK(&p, &d[1]);
match =
IN6_ARE_ADDR_EQUAL(&d[0],
&p);
}
}
break;
case O_FLOW6ID:
match = is_ipv6 &&
flow6id_match(args->f_id.flow_id6,
(ipfw_insn_u32 *) cmd);
break;
case O_EXT_HDR:
match = is_ipv6 &&
(ext_hd & ((ipfw_insn *) cmd)->arg1);
break;
case O_IP6:
match = is_ipv6;
break;
#endif
case O_IP4:
match = is_ipv4;
break;
case O_TAG: {
struct m_tag *mtag;
uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
/* Packet is already tagged with this tag? */
mtag = m_tag_locate(m, MTAG_IPFW, tag, NULL);
/* We have `untag' action when F_NOT flag is
* present. And we must remove this mtag from
* mbuf and reset `match' to zero (`match' will
* be inversed later).
* Otherwise we should allocate new mtag and
* push it into mbuf.
*/
if (cmd->len & F_NOT) { /* `untag' action */
if (mtag != NULL)
m_tag_delete(m, mtag);
match = 0;
} else if (mtag == NULL) {
if ((mtag = m_tag_alloc(MTAG_IPFW,
tag, 0, M_NOWAIT)) != NULL)
m_tag_prepend(m, mtag);
match = 1;
}
break;
}
case O_FIB: /* try match the specified fib */
if (args->f_id.fib == cmd->arg1)
match = 1;
break;
case O_TAGGED: {
struct m_tag *mtag;
uint32_t tag = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
if (cmdlen == 1) {
match = m_tag_locate(m, MTAG_IPFW,
tag, NULL) != NULL;
break;
}
/* we have ranges */
for (mtag = m_tag_first(m);
mtag != NULL && !match;
mtag = m_tag_next(m, mtag)) {
uint16_t *p;
int i;
if (mtag->m_tag_cookie != MTAG_IPFW)
continue;
p = ((ipfw_insn_u16 *)cmd)->ports;
i = cmdlen - 1;
for(; !match && i > 0; i--, p += 2)
match =
mtag->m_tag_id >= p[0] &&
mtag->m_tag_id <= p[1];
}
break;
}
/*
* The second set of opcodes represents 'actions',
* i.e. the terminal part of a rule once the packet
* matches all previous patterns.
* Typically there is only one action for each rule,
* and the opcode is stored at the end of the rule
* (but there are exceptions -- see below).
*
* In general, here we set retval and terminate the
* outer loop (would be a 'break 3' in some language,
* but we need to set l=0, done=1)
*
* Exceptions:
* O_COUNT and O_SKIPTO actions:
* instead of terminating, we jump to the next rule
* (setting l=0), or to the SKIPTO target (setting
* f/f_len, cmd and l as needed), respectively.
*
* O_TAG, O_LOG and O_ALTQ action parameters:
* perform some action and set match = 1;
*
* O_LIMIT and O_KEEP_STATE: these opcodes are
* not real 'actions', and are stored right
* before the 'action' part of the rule.
* These opcodes try to install an entry in the
* state tables; if successful, we continue with
* the next opcode (match=1; break;), otherwise
* the packet must be dropped (set retval,
* break loops with l=0, done=1)
*
* O_PROBE_STATE and O_CHECK_STATE: these opcodes
* cause a lookup of the state table, and a jump
* to the 'action' part of the parent rule
* if an entry is found, or
* (CHECK_STATE only) a jump to the next rule if
* the entry is not found.
* The result of the lookup is cached so that
* further instances of these opcodes become NOPs.
* The jump to the next rule is done by setting
* l=0, cmdlen=0.
*/
case O_LIMIT:
case O_KEEP_STATE:
if (ipfw_install_state(f,
(ipfw_insn_limit *)cmd, args, tablearg)) {
/* error or limit violation */
retval = IP_FW_DENY;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
}
match = 1;
break;
case O_PROBE_STATE:
case O_CHECK_STATE:
/*
* dynamic rules are checked at the first
* keep-state or check-state occurrence,
* with the result being stored in dyn_dir.
* The compiler introduces a PROBE_STATE
* instruction for us when we have a
* KEEP_STATE (because PROBE_STATE needs
* to be run first).
*/
if (dyn_dir == MATCH_UNKNOWN &&
(q = ipfw_lookup_dyn_rule(&args->f_id,
&dyn_dir, proto == IPPROTO_TCP ?
TCP(ulp) : NULL))
!= NULL) {
/*
* Found dynamic entry, update stats
* and jump to the 'action' part of
* the parent rule by setting
* f, cmd, l and clearing cmdlen.
*/
q->pcnt++;
q->bcnt += pktlen;
/* XXX we would like to have f_pos
* readily accessible in the dynamic
* rule, instead of having to
* lookup q->rule.
*/
f = q->rule;
f_pos = ipfw_find_rule(chain,
f->rulenum, f->id);
cmd = ACTION_PTR(f);
l = f->cmd_len - f->act_ofs;
ipfw_dyn_unlock();
cmdlen = 0;
match = 1;
break;
}
/*
* Dynamic entry not found. If CHECK_STATE,
* skip to next rule, if PROBE_STATE just
* ignore and continue with next opcode.
*/
if (cmd->opcode == O_CHECK_STATE)
l = 0; /* exit inner loop */
match = 1;
break;
case O_ACCEPT:
retval = 0; /* accept */
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_PIPE:
case O_QUEUE:
set_match(args, f_pos, chain);
args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
if (cmd->opcode == O_PIPE)
args->rule.info |= IPFW_IS_PIPE;
if (V_fw_one_pass)
args->rule.info |= IPFW_ONEPASS;
retval = IP_FW_DUMMYNET;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_DIVERT:
case O_TEE:
if (args->eh) /* not on layer 2 */
break;
/* otherwise this is terminal */
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
retval = (cmd->opcode == O_DIVERT) ?
IP_FW_DIVERT : IP_FW_TEE;
set_match(args, f_pos, chain);
args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
break;
case O_COUNT:
f->pcnt++; /* update stats */
f->bcnt += pktlen;
f->timestamp = time_uptime;
l = 0; /* exit inner loop */
break;
case O_SKIPTO:
f->pcnt++; /* update stats */
f->bcnt += pktlen;
f->timestamp = time_uptime;
/* If possible use cached f_pos (in f->next_rule),
* whose version is written in f->next_rule
* (horrible hacks to avoid changing the ABI).
*/
if (cmd->arg1 != IP_FW_TABLEARG &&
(uintptr_t)f->x_next == chain->id) {
f_pos = (uintptr_t)f->next_rule;
} else {
int i = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
/* make sure we do not jump backward */
if (i <= f->rulenum)
i = f->rulenum + 1;
f_pos = ipfw_find_rule(chain, i, 0);
/* update the cache */
if (cmd->arg1 != IP_FW_TABLEARG) {
f->next_rule =
(void *)(uintptr_t)f_pos;
f->x_next =
(void *)(uintptr_t)chain->id;
}
}
/*
* Skip disabled rules, and re-enter
* the inner loop with the correct
* f_pos, f, l and cmd.
* Also clear cmdlen and skip_or
*/
for (; f_pos < chain->n_rules - 1 &&
(V_set_disable &
(1 << chain->map[f_pos]->set));
f_pos++)
;
/* Re-enter the inner loop at the skipto rule. */
f = chain->map[f_pos];
l = f->cmd_len;
cmd = f->cmd;
match = 1;
cmdlen = 0;
skip_or = 0;
continue;
break; /* not reached */
case O_REJECT:
/*
* Drop the packet and send a reject notice
* if the packet is not ICMP (or is an ICMP
* query), and it is not multicast/broadcast.
*/
if (hlen > 0 && is_ipv4 && offset == 0 &&
(proto != IPPROTO_ICMP ||
is_icmp_query(ICMP(ulp))) &&
!(m->m_flags & (M_BCAST|M_MCAST)) &&
!IN_MULTICAST(ntohl(dst_ip.s_addr))) {
send_reject(args, cmd->arg1, iplen, ip);
m = args->m;
}
/* FALLTHROUGH */
#ifdef INET6
case O_UNREACH6:
if (hlen > 0 && is_ipv6 &&
((offset & IP6F_OFF_MASK) == 0) &&
(proto != IPPROTO_ICMPV6 ||
(is_icmp6_query(icmp6_type) == 1)) &&
!(m->m_flags & (M_BCAST|M_MCAST)) &&
!IN6_IS_ADDR_MULTICAST(&args->f_id.dst_ip6)) {
send_reject6(
args, cmd->arg1, hlen,
(struct ip6_hdr *)ip);
m = args->m;
}
/* FALLTHROUGH */
#endif
case O_DENY:
retval = IP_FW_DENY;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_FORWARD_IP:
if (args->eh) /* not valid on layer2 pkts */
break;
if (!q || dyn_dir == MATCH_FORWARD) {
struct sockaddr_in *sa;
sa = &(((ipfw_insn_sa *)cmd)->sa);
if (sa->sin_addr.s_addr == INADDR_ANY) {
bcopy(sa, &args->hopstore,
sizeof(*sa));
args->hopstore.sin_addr.s_addr =
htonl(tablearg);
args->next_hop = &args->hopstore;
} else {
args->next_hop = sa;
}
}
retval = IP_FW_PASS;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_NETGRAPH:
case O_NGTEE:
set_match(args, f_pos, chain);
args->rule.info = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
if (V_fw_one_pass)
args->rule.info |= IPFW_ONEPASS;
retval = (cmd->opcode == O_NETGRAPH) ?
IP_FW_NETGRAPH : IP_FW_NGTEE;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_SETFIB:
f->pcnt++; /* update stats */
f->bcnt += pktlen;
f->timestamp = time_uptime;
M_SETFIB(m, cmd->arg1);
args->f_id.fib = cmd->arg1;
l = 0; /* exit inner loop */
break;
case O_NAT:
if (!IPFW_NAT_LOADED) {
retval = IP_FW_DENY;
} else {
struct cfg_nat *t;
int nat_id;
set_match(args, f_pos, chain);
t = ((ipfw_insn_nat *)cmd)->nat;
if (t == NULL) {
nat_id = (cmd->arg1 == IP_FW_TABLEARG) ?
tablearg : cmd->arg1;
t = (*lookup_nat_ptr)(&chain->nat, nat_id);
if (t == NULL) {
retval = IP_FW_DENY;
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
}
if (cmd->arg1 != IP_FW_TABLEARG)
((ipfw_insn_nat *)cmd)->nat = t;
}
retval = ipfw_nat_ptr(args, t, m);
}
l = 0; /* exit inner loop */
done = 1; /* exit outer loop */
break;
case O_REASS: {
int ip_off;
f->pcnt++;
f->bcnt += pktlen;
l = 0; /* in any case exit inner loop */
ip_off = ntohs(ip->ip_off);
/* if not fragmented, go to next rule */
if ((ip_off & (IP_MF | IP_OFFMASK)) == 0)
break;
/*
* ip_reass() expects len & off in host
* byte order.
*/
SET_HOST_IPLEN(ip);
args->m = m = ip_reass(m);
/*
* do IP header checksum fixup.
*/
if (m == NULL) { /* fragment got swallowed */
retval = IP_FW_DENY;
} else { /* good, packet complete */
int hlen;
ip = mtod(m, struct ip *);
hlen = ip->ip_hl << 2;
SET_NET_IPLEN(ip);
ip->ip_sum = 0;
if (hlen == sizeof(struct ip))
ip->ip_sum = in_cksum_hdr(ip);
else
ip->ip_sum = in_cksum(m, hlen);
retval = IP_FW_REASS;
set_match(args, f_pos, chain);
}
done = 1; /* exit outer loop */
break;
}
default:
panic("-- unknown opcode %d\n", cmd->opcode);
} /* end of switch() on opcodes */
/*
* if we get here with l=0, then match is irrelevant.
*/
if (cmd->len & F_NOT)
match = !match;
if (match) {
if (cmd->len & F_OR)
skip_or = 1;
} else {
if (!(cmd->len & F_OR)) /* not an OR block, */
break; /* try next rule */
}
} /* end of inner loop, scan opcodes */
if (done)
break;
/* next_rule:; */ /* try next rule */
} /* end of outer for, scan rules */
if (done) {
struct ip_fw *rule = chain->map[f_pos];
/* Update statistics */
rule->pcnt++;
rule->bcnt += pktlen;
rule->timestamp = time_uptime;
} else {
retval = IP_FW_DENY;
printf("ipfw: ouch!, skip past end of rules, denying packet\n");
}
IPFW_RUNLOCK(chain);
#ifdef __FreeBSD__
if (ucred_cache != NULL)
crfree(ucred_cache);
#endif
return (retval);
pullup_failed:
if (V_fw_verbose)
printf("ipfw: pullup failed\n");
return (IP_FW_DENY);
}
/*
* Module and VNET glue
*/
/*
* Stuff that must be initialised only on boot or module load
*/
static int
ipfw_init(void)
{
int error = 0;
ipfw_dyn_attach();
/*
* Only print out this stuff the first time around,
* when called from the sysinit code.
*/
printf("ipfw2 "
#ifdef INET6
"(+ipv6) "
#endif
"initialized, divert %s, nat %s, "
"rule-based forwarding "
#ifdef IPFIREWALL_FORWARD
"enabled, "
#else
"disabled, "
#endif
"default to %s, logging ",
#ifdef IPDIVERT
"enabled",
#else
"loadable",
#endif
#ifdef IPFIREWALL_NAT
"enabled",
#else
"loadable",
#endif
default_to_accept ? "accept" : "deny");
/*
* Note: V_xxx variables can be accessed here but the vnet specific
* initializer may not have been called yet for the VIMAGE case.
* Tuneables will have been processed. We will print out values for
* the default vnet.
* XXX This should all be rationalized AFTER 8.0
*/
if (V_fw_verbose == 0)
printf("disabled\n");
else if (V_verbose_limit == 0)
printf("unlimited\n");
else
printf("limited to %d packets/entry by default\n",
V_verbose_limit);
ipfw_log_bpf(1); /* init */
return (error);
}
/*
* Called for the removal of the last instance only on module unload.
*/
static void
ipfw_destroy(void)
{
ipfw_log_bpf(0); /* uninit */
ipfw_dyn_detach();
printf("IP firewall unloaded\n");
}
/*
* Stuff that must be initialized for every instance
* (including the first of course).
*/
static int
vnet_ipfw_init(const void *unused)
{
int error;
struct ip_fw *rule = NULL;
struct ip_fw_chain *chain;
chain = &V_layer3_chain;
/* First set up some values that are compile time options */
V_autoinc_step = 100; /* bounded to 1..1000 in add_rule() */
V_fw_deny_unknown_exthdrs = 1;
#ifdef IPFIREWALL_VERBOSE
V_fw_verbose = 1;
#endif
#ifdef IPFIREWALL_VERBOSE_LIMIT
V_verbose_limit = IPFIREWALL_VERBOSE_LIMIT;
#endif
#ifdef IPFIREWALL_NAT
LIST_INIT(&chain->nat);
#endif
/* insert the default rule and create the initial map */
chain->n_rules = 1;
chain->static_len = sizeof(struct ip_fw);
chain->map = malloc(sizeof(struct ip_fw *), M_IPFW, M_NOWAIT | M_ZERO);
if (chain->map)
rule = malloc(chain->static_len, M_IPFW, M_NOWAIT | M_ZERO);
if (rule == NULL) {
if (chain->map)
free(chain->map, M_IPFW);
printf("ipfw2: ENOSPC initializing default rule "
"(support disabled)\n");
return (ENOSPC);
}
error = ipfw_init_tables(chain);
if (error) {
panic("init_tables"); /* XXX Marko fix this ! */
}
/* fill and insert the default rule */
rule->act_ofs = 0;
rule->rulenum = IPFW_DEFAULT_RULE;
rule->cmd_len = 1;
rule->set = RESVD_SET;
rule->cmd[0].len = 1;
rule->cmd[0].opcode = default_to_accept ? O_ACCEPT : O_DENY;
chain->rules = chain->default_rule = chain->map[0] = rule;
chain->id = rule->id = 1;
IPFW_LOCK_INIT(chain);
ipfw_dyn_init();
/* First set up some values that are compile time options */
V_ipfw_vnet_ready = 1; /* Open for business */
/*
* Hook the sockopt handler, and the layer2 (V_ip_fw_chk_ptr)
* and pfil hooks for ipv4 and ipv6. Even if the latter two fail
* we still keep the module alive because the sockopt and
* layer2 paths are still useful.
* ipfw[6]_hook return 0 on success, ENOENT on failure,
* so we can ignore the exact return value and just set a flag.
*
* Note that V_fw[6]_enable are manipulated by a SYSCTL_PROC so
* changes in the underlying (per-vnet) variables trigger
* immediate hook()/unhook() calls.
* In layer2 we have the same behaviour, except that V_ether_ipfw
* is checked on each packet because there are no pfil hooks.
*/
V_ip_fw_ctl_ptr = ipfw_ctl;
V_ip_fw_chk_ptr = ipfw_chk;
error = ipfw_attach_hooks(1);
return (error);
}
/*
* Called for the removal of each instance.
*/
static int
vnet_ipfw_uninit(const void *unused)
{
struct ip_fw *reap, *rule;
struct ip_fw_chain *chain = &V_layer3_chain;
int i;
V_ipfw_vnet_ready = 0; /* tell new callers to go away */
/*
* disconnect from ipv4, ipv6, layer2 and sockopt.
* Then grab, release and grab again the WLOCK so we make
* sure the update is propagated and nobody will be in.
*/
(void)ipfw_attach_hooks(0 /* detach */);
V_ip_fw_chk_ptr = NULL;
V_ip_fw_ctl_ptr = NULL;
IPFW_UH_WLOCK(chain);
IPFW_UH_WUNLOCK(chain);
IPFW_UH_WLOCK(chain);
IPFW_WLOCK(chain);
IPFW_WUNLOCK(chain);
IPFW_WLOCK(chain);
ipfw_dyn_uninit(0); /* run the callout_drain */
ipfw_destroy_tables(chain);
reap = NULL;
for (i = 0; i < chain->n_rules; i++) {
rule = chain->map[i];
rule->x_next = reap;
reap = rule;
}
if (chain->map)
free(chain->map, M_IPFW);
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
if (reap != NULL)
ipfw_reap_rules(reap);
IPFW_LOCK_DESTROY(chain);
ipfw_dyn_uninit(1); /* free the remaining parts */
return 0;
}
/*
* Module event handler.
* In general we have the choice of handling most of these events by the
* event handler or by the (VNET_)SYS(UN)INIT handlers. I have chosen to
* use the SYSINIT handlers as they are more capable of expressing the
* flow of control during module and vnet operations, so this is just
* a skeleton. Note there is no SYSINIT equivalent of the module
* SHUTDOWN handler, but we don't have anything to do in that case anyhow.
*/
static int
ipfw_modevent(module_t mod, int type, void *unused)
{
int err = 0;
switch (type) {
case MOD_LOAD:
/* Called once at module load or
* system boot if compiled in. */
break;
case MOD_QUIESCE:
/* Called before unload. May veto unloading. */
break;
case MOD_UNLOAD:
/* Called during unload. */
break;
case MOD_SHUTDOWN:
/* Called during system shutdown. */
break;
default:
err = EOPNOTSUPP;
break;
}
return err;
}
static moduledata_t ipfwmod = {
"ipfw",
ipfw_modevent,
0
};
/* Define startup order. */
#define IPFW_SI_SUB_FIREWALL SI_SUB_PROTO_IFATTACHDOMAIN
#define IPFW_MODEVENT_ORDER (SI_ORDER_ANY - 255) /* On boot slot in here. */
#define IPFW_MODULE_ORDER (IPFW_MODEVENT_ORDER + 1) /* A little later. */
#define IPFW_VNET_ORDER (IPFW_MODEVENT_ORDER + 2) /* Later still. */
DECLARE_MODULE(ipfw, ipfwmod, IPFW_SI_SUB_FIREWALL, IPFW_MODEVENT_ORDER);
MODULE_VERSION(ipfw, 2);
/* should declare some dependencies here */
/*
* Starting up. Done in order after ipfwmod() has been called.
* VNET_SYSINIT is also called for each existing vnet and each new vnet.
*/
SYSINIT(ipfw_init, IPFW_SI_SUB_FIREWALL, IPFW_MODULE_ORDER,
ipfw_init, NULL);
VNET_SYSINIT(vnet_ipfw_init, IPFW_SI_SUB_FIREWALL, IPFW_VNET_ORDER,
vnet_ipfw_init, NULL);
/*
* Closing up shop. These are done in REVERSE ORDER, but still
* after ipfwmod() has been called. Not called on reboot.
* VNET_SYSUNINIT is also called for each exiting vnet as it exits.
* or when the module is unloaded.
*/
SYSUNINIT(ipfw_destroy, IPFW_SI_SUB_FIREWALL, IPFW_MODULE_ORDER,
ipfw_destroy, NULL);
VNET_SYSUNINIT(vnet_ipfw_uninit, IPFW_SI_SUB_FIREWALL, IPFW_VNET_ORDER,
vnet_ipfw_uninit, NULL);
/* end of file */
| {
"pile_set_name": "Github"
} |
//------------------------------------------------------------------------------
// <copyright file="Logging.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Net.PeerToPeer
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Runtime.Serialization;
using System.Security.Permissions;
/// <remarks>
/// The PeerToPeerException class encpasulates the exceptions for
/// PeerToPeer classes.
/// NOTE:
/// This class is marked serializable but does not implement
/// ISerializable interface. There are no private/public properties
/// we keep track across the serialization. The base class message
/// and inner exceptions are used.
/// </remarks>
[Serializable]
public class PeerToPeerException : Exception, ISerializable
{
private const UInt32 FACILITY_P2P = 99;
public PeerToPeerException() { }
/// <summary>
/// Construtor
/// </summary>
/// <param name="message"></param>
public PeerToPeerException(string message) : base(message) { }
/// <summary>
/// Constructor
/// </summary>
/// <param name="message"></param>
/// <param name="innerException"></param>
public PeerToPeerException(string message, Exception innerException) : base(message, innerException) { }
/// <summary>
/// HRESULT Structure
/// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
/// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
/// +---+-+-+-----------------------+-------------------------------+
/// |Sev|C|R| Facility | Code |
/// +---+-+-+-----------------------+-------------------------------+
///
/// The intent here is that when we get a HRESULT from a P2P.dll,
/// we need to get the message from the P2p.dll resource table.
/// If the HRESULT is something like E_INVALIDARG, we need to get the
/// message from the SYSTEM table.
/// Apart from the native exception message, we would like to provide
/// a friendly message to explain the context under which the exception
/// occurred from managed code developers.
/// So we first try to get the message from the P2P.dll if the HRESULT
/// comes with a facility ID for P2P. Otherwise we get the exception message from
/// system. We then construct a Win32Exception and set this as an inner exception
///
/// If in case we can't get the message from either system or P2p, then
/// we try the Marshal class and throw a exception from the HRESULT
///
/// If all else fails we simply throw an exception with no inner
/// exception but still give the HRESULT
///
/// A note that we are getting the handle for P2p.dll from the LoadLibrary
/// we originally did for checking if P2P.dll is present on the system.
/// Since we are getting the underlying handle, there is a possibility that
/// the Library is freed [AppDomain shutdown] and we are trying to
/// use the handle. The code is in a try catch block here so that
/// we catch these situations and still recover.
/// </summary>
/// <param name="message">The error message that we would like to set as the message for the exception</param>///
/// <param name="hr">The error code</param>
/// <returns>a PeerToPeerException</returns>
// <SecurityKernel Critical="True" Ring="0">
// <CallsSuppressUnmanagedCode Name="UnsafeSystemNativeMethods.FormatMessage(System.Net.FormatMessageFlags,System.IntPtr,System.UInt32,System.UInt32,System.IntPtr&,System.UInt32,System.IntPtr):System.UInt32" />
// <CallsSuppressUnmanagedCode Name="UnsafeSystemNativeMethods.LocalFree(System.IntPtr):System.UInt32" />
// <SatisfiesLinkDemand Name="Marshal.PtrToStringUni(System.IntPtr):System.String" />
// <SatisfiesLinkDemand Name="Win32Exception..ctor(System.Int32,System.String)" />
// <SatisfiesLinkDemand Name="Marshal.GetExceptionForHR(System.Int32):System.Exception" />
// <ReferencesCritical Name="Method: PeerToPeerOSHelper.get_P2PModuleHandle():System.IntPtr" Ring="1" />
// </SecurityKernel>
[System.Security.SecurityCritical]
internal static PeerToPeerException CreateFromHr(string message, Int32 hr)
{
PeerToPeerException p2pEx = null;
int facility = ((hr >> 16) & 0x1FFF);
IntPtr NativeMessagePtr = IntPtr.Zero;
try
{
UInt32 dwLength = UnsafeSystemNativeMethods.FormatMessage(
FormatMessageFlags.FORMAT_MESSAGE_ALLOCATE_BUFFER |
FormatMessageFlags.FORMAT_MESSAGE_ARGUMENT_ARRAY |
(facility == FACILITY_P2P ? FormatMessageFlags.FORMAT_MESSAGE_FROM_HMODULE : FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM),
(facility == FACILITY_P2P ? PeerToPeerOSHelper.P2PModuleHandle : IntPtr.Zero),
(uint)(hr),
0,
ref NativeMessagePtr,
0,
IntPtr.Zero);
if (dwLength != 0)
{
string NativeMessage = Marshal.PtrToStringUni(NativeMessagePtr);
p2pEx = new PeerToPeerException(message, new Win32Exception(hr, NativeMessage));
}
else
{
p2pEx = new PeerToPeerException(message, Marshal.GetExceptionForHR(hr));
}
}
catch(Exception ex)
{
Logging.P2PTraceSource.TraceEvent(TraceEventType.Warning, 0, "Could not get the error message for error code {0} - Exception {1}", hr, ex);
if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException)
{
throw;
}
}
finally
{
if (NativeMessagePtr != IntPtr.Zero)
{
UnsafeSystemNativeMethods.LocalFree(NativeMessagePtr);
}
}
if (p2pEx == null)
{
Logging.P2PTraceSource.TraceEvent(TraceEventType.Warning, 0, "Could not get the error message for error code {0}", hr);
p2pEx = new PeerToPeerException(message + "Underlying native error " + hr);
}
Logging.P2PTraceSource.TraceEvent(TraceEventType.Error, 0, "Exception: {0}", p2pEx);
return p2pEx;
}
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
protected PeerToPeerException(SerializationInfo info, StreamingContext context) : base (info, context) {}
// <SecurityKernel Critical="True" Ring="0">
// <SatisfiesLinkDemand Name="Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext):System.Void" />
// </SecurityKernel>
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.Net.dll is still using pre-v4 security model and needs this demand")]
[System.Security.SecurityCritical]
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) {
GetObjectData(info, context);
}
// <SecurityKernel Critical="True" Ring="0">
// <SatisfiesLinkDemand Name="Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext):System.Void" />
// </SecurityKernel>
[SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase", Justification = "System.Net.dll is still using pre-v4 security model and needs this demand")]
[System.Security.SecurityCritical]
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
| {
"pile_set_name": "Github"
} |
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
if "%2"=="" (
echo Usage: launch.bat ^<program^> ^[action^] ^<outfile^>
exit /b 1
)
if "%1"=="collector" (
%1 %2 > "%3" 2> "%3".err
) else (
%1 > "%2" 2> "%2".err
) | {
"pile_set_name": "Github"
} |
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
** This notice applies to any and all portions of this file
* that are not between comment pairs USER CODE BEGIN and
* USER CODE END. Other portions of this file, whether
* inserted by the user or by software development tools
* are owned by their respective copyright owners.
*
* COPYRIGHT(c) 2018 STMicroelectronics
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32l4xx_hal.h"
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <sfud.h>
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
QSPI_HandleTypeDef hqspi;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_QUADSPI_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
void sfud_demo(uint32_t addr, size_t size, uint8_t *data);
#define SFUD_DEMO_TEST_BUFFER_SIZE 1024
static uint8_t sfud_demo_test_buf[SFUD_DEMO_TEST_BUFFER_SIZE];
/* USER CODE END 0 */
/**
* @brief The application entry point.
*
* @retval None
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_QUADSPI_Init();
/* USER CODE BEGIN 2 */
/* SFUD initialize */
if (sfud_init() == SFUD_SUCCESS)
{
/* enable qspi fast read mode, set four data lines width */
sfud_qspi_fast_read_enable(sfud_get_device(SFUD_W25_DEVICE_INDEX), 4);
sfud_demo(0, sizeof(sfud_demo_test_buf), sfud_demo_test_buf);
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 20;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure the Systick interrupt time
*/
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
/**Configure the Systick
*/
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
/* QUADSPI init function */
static void MX_QUADSPI_Init(void)
{
/* QUADSPI parameter configuration*/
hqspi.Instance = QUADSPI;
hqspi.Init.ClockPrescaler = 1;
hqspi.Init.FifoThreshold = 4;
hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;
hqspi.Init.FlashSize = 18;
hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_4_CYCLE;
hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
if (HAL_QSPI_Init(&hqspi) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* USART1 init function */
static void MX_USART1_UART_Init(void)
{
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/** Configure pins as
* Analog
* Input
* Output
* EVENT_OUT
* EXTI
*/
static void MX_GPIO_Init(void)
{
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
}
/* USER CODE BEGIN 4 */
/**
* SFUD demo for the first flash device test.
*
* @param addr flash start address
* @param size test flash size
* @param size test flash data buffer
*/
void sfud_demo(uint32_t addr, size_t size, uint8_t *data)
{
sfud_err result = SFUD_SUCCESS;
extern sfud_flash *sfud_dev;
const sfud_flash *flash = sfud_get_device(SFUD_W25_DEVICE_INDEX);
size_t i;
/* prepare write data */
for (i = 0; i < size; i++)
{
data[i] = i;
}
/* erase test */
result = sfud_erase(flash, addr, size);
if (result == SFUD_SUCCESS)
{
printf("Erase the %s flash data finish. Start from 0x%08X, size is %zu.\r\n", flash->name, addr, size);
}
else
{
printf("Erase the %s flash data failed.\r\n", flash->name);
return;
}
/* write test */
result = sfud_write(flash, addr, size, data);
if (result == SFUD_SUCCESS)
{
printf("Write the %s flash data finish. Start from 0x%08X, size is %zu.\r\n", flash->name, addr, size);
}
else
{
printf("Write the %s flash data failed.\r\n", flash->name);
return;
}
/* read test */
result = sfud_read(flash, addr, size, data);
if (result == SFUD_SUCCESS)
{
printf("Read the %s flash data success. Start from 0x%08X, size is %zu. The data is:\r\n", flash->name, addr, size);
printf("Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n");
for (i = 0; i < size; i++)
{
if (i % 16 == 0)
{
printf("[%08X] ", addr + i);
}
printf("%02X ", data[i]);
if (((i + 1) % 16 == 0) || i == size - 1)
{
printf("\r\n");
}
}
printf("\r\n");
}
else
{
printf("Read the %s flash data failed.\r\n", flash->name);
}
/* data check */
for (i = 0; i < size; i++)
{
if (data[i] != i % 256)
{
printf("Read and check write data has an error. Write the %s flash data failed.\r\n", flash->name);
break;
}
}
if (i == size)
{
printf("The %s flash test is success.\r\n", flash->name);
}
}
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @param file: The file name as string.
* @param line: The line in file as a number.
* @retval None
*/
void _Error_Handler(char *file, int line)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* Copyright (C) 2017 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.
*/
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="long_press_widget_to_add" msgid="4001616142797446267">"ແຕະຄ້າງໄວ້ເພື່ອຮັບປຸ່ມລັດ."</string>
<string name="long_accessible_way_to_add" msgid="2725225828389948328">"ແຕະສອງເທື່ອຄ້າງໄວ້ເພື່ອຮັບປຸ່ມລັດ ຫຼື ໃຊ້ຄຳສັ່ງແບບກຳນົດເອງ."</string>
<string name="widget_button_text" msgid="4221900832360456858">"ປຸ່ມລັດ"</string>
<string name="widgets_bottom_sheet_title" msgid="3949835990909395998">"ປຸ່ມລັດ <xliff:g id="NAME">%1$s</xliff:g>"</string>
</resources>
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.javafx.util.converter;
import javafx.util.converter.LongStringConverter;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
/**
*/
public class LongStringConverterTest {
private LongStringConverter converter;
@Before public void setup() {
converter = new LongStringConverter();
}
@Test public void fromString_testValidStringInput() {
assertEquals(Long.valueOf(10), converter.fromString("10"));
}
@Test public void fromString_testValidStringInputWithWhiteSpace() {
assertEquals(Long.valueOf(10), converter.fromString(" 10 "));
}
@Test public void toString_validInput() {
assertEquals("10", converter.toString(10L));
}
}
| {
"pile_set_name": "Github"
} |
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is JavaScript Engine testing utilities.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Jesse Ruderman
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//-----------------------------------------------------------------------------
var BUGNUMBER = 380237;
var summary = 'Decompilation of generator expressions';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
expect = 'No Error';
actual = '';
try
{
var g = ((yield i) for (i in [1,2,3]));
actual = 'No Error';
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': top level');
function test()
{
enterFunc ('test');
printBugNumber(BUGNUMBER);
printStatus (summary);
var f = (function() { g = (d for (d in [0]) for (e in [1])); });
expect = 'function() { g = (d for (d in [0]) for (e in [1])); }';
actual = f + '';
compareSource(expect, actual, summary + ': see bug 380506');
f = function() { return (1 for (i in [])) };
expect = 'function() { return (1 for (i in [])); }';
actual = f + '';
compareSource(expect, actual, summary);
f = function() { with((x for (x in []))) { } };
expect = 'function() { with(x for (x in [])) { } }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function() { (1 for (w in []) if (0)) });
expect = 'function() { (1 for (w in []) if (false)); }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function() { (1 for (w in []) if (x)) });
expect = 'function() { (1 for (w in []) if (x)); }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function() { (1 for (w in []) if (1)) });
expect = 'function() { (1 for (w in []) ); }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function() { (x for ([{}, {}] in [])); });
expect = 'function() { (x for ([[], []] in [])); }';
actual = f + '';
compareSource(expect, actual, summary);
expect = 'SyntaxError: invalid assignment left-hand side';
actual = '';
try
{
eval('(function() { (x for each (x in [])) = 3; })');
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL');
f = (function() { (x*x for (x in a)); });
expect = 'function() { (x*x for (x in a)); }';
actual = f + '';
compareSource(expect, actual, summary);
f = (function () { (1 for (y in (yield 3))); });
expect = 'function () { (1 for (y in yield 3)); }';
actual = f + '';
compareSource(expect, actual, summary);
expect = 'SyntaxError: invalid delete operand';
try
{
eval('(function () { delete (x for (x in [])); })');
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': Do not Assert: *pc == JSOP_CALL');
f = (function() { ([yield] for (x in [])); });
expect = 'function() { ([(yield)] for (x in [])); }';
actual = f + '';
compareSource(expect, actual, summary);
f = function() { if(1, (x for (x in []))) { } };
expect = 'function() { if(1, (x for (x in []))) { } }';
actual = f + '';
compareSource(expect, actual, summary);
f = function () {return(i*j for each (i in [1,2,3,4])
for each (j in [5,6,7,8]))};
expect = 'function () {return(i*j for each (i in [1,2,3,4]) ' +
'for each (j in [5,6,7,8]));}';
actual = f + '';
compareSource(expect, actual, summary);
expect = 'No Error';
actual = '';
try
{
var g = ((yield i) for (i in [1,2,3]));
actual = 'No Error';
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary + ': nested');
f = function() { try { } catch(x if (1 for (x in []))) { } finally { } };
expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }';
actual = f + '';
compareSource(expect, actual, summary);
f = eval(uneval(f));
expect = 'function() { try {} catch(x if (1 for (x in []))) {} finally {} }';
actual = f + '';
compareSource(expect, actual, summary + ': eval(uneval())');
f = function() { if (1, (x for (x in []))) { } };
expect = 'function() { if (1, (x for (x in []))) { } }';
actual = f + '';
compareSource(expect, actual, summary);
f = function() { ((a, b) for (x in [])) };
expect = 'function() { ((a, b) for (x in [])); }';
actual = f + '';
compareSource(expect, actual, summary);
exitFunc ('test');
}
| {
"pile_set_name": "Github"
} |
3.0.1 / 2017-04-27
==================
* [Fix] deep extending should work with a non-object (#46)
* [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`
* [Tests] up to `node` `v7.9`, `v6.10`, `v4.8`; improve matrix
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG.
* [Docs] Add example to readme (#34)
3.0.0 / 2015-07-01
==================
* [Possible breaking change] Use global "strict" directive (#32)
* [Tests] `int` is an ES3 reserved word
* [Tests] Test up to `io.js` `v2.3`
* [Tests] Add `npm run eslint`
* [Dev Deps] Update `covert`, `jscs`
2.0.1 / 2015-04-25
==================
* Use an inline `isArray` check, for ES3 browsers. (#27)
* Some old browsers fail when an identifier is `toString`
* Test latest `node` and `io.js` versions on `travis-ci`; speed up builds
* Add license info to package.json (#25)
* Update `tape`, `jscs`
* Adding a CHANGELOG
2.0.0 / 2014-10-01
==================
* Increase code coverage to 100%; run code coverage as part of tests
* Add `npm run lint`; Run linter as part of tests
* Remove nodeType and setInterval checks in isPlainObject
* Updating `tape`, `jscs`, `covert`
* General style and README cleanup
1.3.0 / 2014-06-20
==================
* Add component.json for browser support (#18)
* Use SVG for badges in README (#16)
* Updating `tape`, `covert`
* Updating travis-ci to work with multiple node versions
* Fix `deep === false` bug (returning target as {}) (#14)
* Fixing constructor checks in isPlainObject
* Adding additional test coverage
* Adding `npm run coverage`
* Add LICENSE (#13)
* Adding a warning about `false`, per #11
* General style and whitespace cleanup
1.2.1 / 2013-09-14
==================
* Fixing hasOwnProperty bugs that would only have shown up in specific browsers. Fixes #8
* Updating `tape`
1.2.0 / 2013-09-02
==================
* Updating the README: add badges
* Adding a missing variable reference.
* Using `tape` instead of `buster` for tests; add more tests (#7)
* Adding node 0.10 to Travis CI (#6)
* Enabling "npm test" and cleaning up package.json (#5)
* Add Travis CI.
1.1.3 / 2012-12-06
==================
* Added unit tests.
* Ensure extend function is named. (Looks nicer in a stack trace.)
* README cleanup.
1.1.1 / 2012-11-07
==================
* README cleanup.
* Added installation instructions.
* Added a missing semicolon
1.0.0 / 2012-04-08
==================
* Initial commit
| {
"pile_set_name": "Github"
} |
/*
* The Sleuth Kit
*
* Brian Carrier [carrier <at> sleuthkit [dot] org]
* Copyright (c) 2005-2011 Brian Carrier. All rights reserved
*
* This software is distributed under the Common Public License 1.0
*/
/*
* Header files for AFF-specific data structures and functions.
*/
#ifndef _AFF_H
#define _AFF_H
#if HAVE_LIBAFFLIB
#include <afflib/afflib.h>
// mingw's pthread.h will try to read a config.h if HAVE_CONFIG_H
#if HAVE_CONFIG_H
#undef HAVE_CONFIG_H
#include <afflib/afflib_i.h>
#define HAVE_CONFIG_H 1
#else
#include <afflib/afflib_i.h>
#endif
extern TSK_IMG_INFO *aff_open(const TSK_TCHAR * const images[],
unsigned int a_ssize);
/** \internal
* Stores AFF-specific data
*/
typedef struct {
TSK_IMG_INFO img_info;
AFFILE *af_file;
TSK_OFF_T seek_pos; // shared and protected by cache_lock in IMG_INFO
uint16_t type; /* TYPE - uses AF_IDENTIFY_x values */
} IMG_AFF_INFO;
#endif
#endif
| {
"pile_set_name": "Github"
} |
package ch.epfl.leb.autolase;
/**
* A laser power monitor indicates a class interested in changes to the laser
* power.
*
* @author Thomas Pengo
*/
public interface LaserPowerMonitor {
public void laserPowerChanged(double newLaserPower);
}
| {
"pile_set_name": "Github"
} |
#
# This schedule performs filter-pruning using L1-norm ranking and AGP for the setting the pruning-rate decay.
# The final Linear layer (FC) is also pruned to 70%.
# Curiously, we achieve slightly better Top1, when compared to the same schedule without the FC pruning.
#
# Best Top1: 74.564 (epoch 84) vs. 76.15 baseline (-1.6%)
# No. of Parameters: 10,901,696 (of 25,502,912) = 42.74% dense (57.26% sparse)
# Total MACs: 1,822,031,872 (of 4,089,184,256) = 44.56% compute = 2.24x
# time python3 compress_classifier.py -a=resnet50 --pretrained -p=50 ~/datasets/imagenet/ -j=22 --epochs=100 --lr=0.0005 --compress=resnet50.schedule_agp.filters.yaml --validation-split=0 --num-best-scores=10
#
# Parameters:
# +----+-------------------------------------+--------------------+---------------+----------------+------------+------------+----------+----------+----------+------------+---------+----------+------------+
# | | Name | Shape | NNZ (dense) | NNZ (sparse) | Cols (%) | Rows (%) | Ch (%) | 2D (%) | 3D (%) | Fine (%) | Std | Mean | Abs-Mean |
# |----+-------------------------------------+--------------------+---------------+----------------+------------+------------+----------+----------+----------+------------+---------+----------+------------|
# | 0 | module.conv1.weight | (64, 3, 7, 7) | 9408 | 9408 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.11119 | -0.00042 | 0.06789 |
# | 1 | module.layer1.0.conv1.weight | (32, 64, 1, 1) | 2048 | 2048 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.07661 | -0.00610 | 0.04643 |
# | 2 | module.layer1.0.conv2.weight | (32, 32, 3, 3) | 9216 | 9216 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.04028 | 0.00160 | 0.02608 |
# | 3 | module.layer1.0.conv3.weight | (256, 32, 1, 1) | 8192 | 8192 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03803 | -0.00044 | 0.02407 |
# | 4 | module.layer1.0.downsample.0.weight | (256, 64, 1, 1) | 16384 | 16384 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.05144 | -0.00304 | 0.02863 |
# | 5 | module.layer1.1.conv1.weight | (32, 256, 1, 1) | 8192 | 8192 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03162 | 0.00100 | 0.02178 |
# | 6 | module.layer1.1.conv2.weight | (32, 32, 3, 3) | 9216 | 9216 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03687 | 0.00027 | 0.02591 |
# | 7 | module.layer1.1.conv3.weight | (256, 32, 1, 1) | 8192 | 8192 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03185 | -0.00048 | 0.02030 |
# | 8 | module.layer1.2.conv1.weight | (32, 256, 1, 1) | 8192 | 8192 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03011 | 0.00019 | 0.02205 |
# | 9 | module.layer1.2.conv2.weight | (32, 32, 3, 3) | 9216 | 9216 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03635 | -0.00009 | 0.02744 |
# | 10 | module.layer1.2.conv3.weight | (256, 32, 1, 1) | 8192 | 8192 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02803 | -0.00242 | 0.01684 |
# | 11 | module.layer2.0.conv1.weight | (64, 256, 1, 1) | 16384 | 16384 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.03596 | -0.00125 | 0.02536 |
# | 12 | module.layer2.0.conv2.weight | (64, 64, 3, 3) | 36864 | 36864 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02418 | 0.00002 | 0.01789 |
# | 13 | module.layer2.0.conv3.weight | (512, 64, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02696 | 0.00000 | 0.01652 |
# | 14 | module.layer2.0.downsample.0.weight | (512, 256, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02060 | -0.00044 | 0.01214 |
# | 15 | module.layer2.1.conv1.weight | (64, 512, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01739 | -0.00021 | 0.01075 |
# | 16 | module.layer2.1.conv2.weight | (64, 64, 3, 3) | 36864 | 36864 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02545 | 0.00070 | 0.01662 |
# | 17 | module.layer2.1.conv3.weight | (512, 64, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02249 | -0.00146 | 0.01323 |
# | 18 | module.layer2.2.conv1.weight | (64, 512, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02338 | -0.00056 | 0.01624 |
# | 19 | module.layer2.2.conv2.weight | (64, 64, 3, 3) | 36864 | 36864 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02410 | 0.00015 | 0.01685 |
# | 20 | module.layer2.2.conv3.weight | (512, 64, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02576 | 0.00017 | 0.01794 |
# | 21 | module.layer2.3.conv1.weight | (64, 512, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02341 | -0.00082 | 0.01743 |
# | 22 | module.layer2.3.conv2.weight | (64, 64, 3, 3) | 36864 | 36864 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02380 | -0.00048 | 0.01804 |
# | 23 | module.layer2.3.conv3.weight | (512, 64, 1, 1) | 32768 | 32768 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02311 | -0.00123 | 0.01596 |
# | 24 | module.layer3.0.conv1.weight | (128, 512, 1, 1) | 65536 | 65536 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02988 | -0.00090 | 0.02166 |
# | 25 | module.layer3.0.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01793 | -0.00014 | 0.01335 |
# | 26 | module.layer3.0.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02273 | -0.00044 | 0.01634 |
# | 27 | module.layer3.0.downsample.0.weight | (1024, 512, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01441 | -0.00002 | 0.00988 |
# | 28 | module.layer3.1.conv1.weight | (128, 1024, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01521 | -0.00035 | 0.01075 |
# | 29 | module.layer3.1.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01686 | -0.00003 | 0.01215 |
# | 30 | module.layer3.1.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01961 | -0.00062 | 0.01396 |
# | 31 | module.layer3.2.conv1.weight | (128, 1024, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01551 | -0.00032 | 0.01105 |
# | 32 | module.layer3.2.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01649 | -0.00058 | 0.01217 |
# | 33 | module.layer3.2.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01839 | -0.00051 | 0.01337 |
# | 34 | module.layer3.3.conv1.weight | (128, 1024, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01679 | -0.00058 | 0.01252 |
# | 35 | module.layer3.3.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01554 | -0.00052 | 0.01180 |
# | 36 | module.layer3.3.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01745 | -0.00095 | 0.01283 |
# | 37 | module.layer3.4.conv1.weight | (128, 1024, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01739 | -0.00078 | 0.01312 |
# | 38 | module.layer3.4.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01537 | -0.00063 | 0.01168 |
# | 39 | module.layer3.4.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01709 | -0.00124 | 0.01253 |
# | 40 | module.layer3.5.conv1.weight | (128, 1024, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01870 | -0.00072 | 0.01434 |
# | 41 | module.layer3.5.conv2.weight | (128, 128, 3, 3) | 147456 | 147456 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01530 | -0.00072 | 0.01172 |
# | 42 | module.layer3.5.conv3.weight | (1024, 128, 1, 1) | 131072 | 131072 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01855 | -0.00212 | 0.01395 |
# | 43 | module.layer4.0.conv1.weight | (256, 1024, 1, 1) | 262144 | 262144 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.02219 | -0.00086 | 0.01714 |
# | 44 | module.layer4.0.conv2.weight | (256, 256, 3, 3) | 589824 | 589824 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01231 | -0.00011 | 0.00960 |
# | 45 | module.layer4.0.conv3.weight | (2048, 256, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01452 | -0.00058 | 0.01130 |
# | 46 | module.layer4.0.downsample.0.weight | (2048, 1024, 1, 1) | 2097152 | 2097152 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00903 | -0.00019 | 0.00688 |
# | 47 | module.layer4.1.conv1.weight | (256, 2048, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01434 | -0.00029 | 0.01122 |
# | 48 | module.layer4.1.conv2.weight | (256, 256, 3, 3) | 589824 | 589824 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01229 | -0.00059 | 0.00963 |
# | 49 | module.layer4.1.conv3.weight | (2048, 256, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01432 | 0.00003 | 0.01107 |
# | 50 | module.layer4.2.conv1.weight | (256, 2048, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01774 | -0.00010 | 0.01394 |
# | 51 | module.layer4.2.conv2.weight | (256, 256, 3, 3) | 589824 | 589824 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01076 | -0.00036 | 0.00845 |
# | 52 | module.layer4.2.conv3.weight | (2048, 256, 1, 1) | 524288 | 524288 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.01319 | 0.00018 | 0.00993 |
# | 53 | module.fc.weight | (1000, 2048) | 2048000 | 614400 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 70.00000 | 0.03188 | 0.00306 | 0.01495 |
# | 54 | Total sparsity: | - | 12335296 | 10901696 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 11.62193 | 0.00000 | 0.00000 | 0.00000 |
# +----+-------------------------------------+--------------------+---------------+----------------+------------+------------+----------+----------+----------+------------+---------+----------+------------+
# 2018-12-13 17:32:34,087 - Total sparsity: 11.62
#
# 2018-12-13 17:32:34,087 - --- validate (epoch=99)-----------
# 2018-12-13 17:32:34,088 - 50000 samples (256 per mini-batch)
# 2018-12-13 17:32:50,281 - Epoch: [99][ 50/ 195] Loss 0.734106 Top1 80.734375 Top5 95.226562
# 2018-12-13 17:32:57,293 - Epoch: [99][ 100/ 195] Loss 0.858832 Top1 77.910156 Top5 93.960938
# 2018-12-13 17:33:04,432 - Epoch: [99][ 150/ 195] Loss 0.981425 Top1 75.471354 Top5 92.401042
# 2018-12-13 17:33:10,060 - ==> Top1: 74.426 Top5: 91.962 Loss: 1.025
#
# 2018-12-13 17:33:10,194 - ==> Best Top1: 75.912 on Epoch: 0
# 2018-12-13 17:33:10,194 - ==> Best Top1: 75.492 on Epoch: 1
# 2018-12-13 17:33:10,194 - ==> Best Top1: 74.942 on Epoch: 2
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.564 on Epoch: 84 <======
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.514 on Epoch: 94
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.494 on Epoch: 80
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.488 on Epoch: 91
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.482 on Epoch: 82
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.482 on Epoch: 93
# 2018-12-13 17:33:10,195 - ==> Best Top1: 74.472 on Epoch: 95
# 2018-12-13 17:33:10,195 - Saving checkpoint to: logs/resnet50_filters_v4_with_FC___2018.12.11-172607/resnet50_filters_v4_with_FC_checkpoint.pth.tar
# 2018-12-13 17:33:10,457 - --- test ---------------------
# 2018-12-13 17:33:10,458 - 50000 samples (256 per mini-batch)
# 2018-12-13 17:33:26,953 - Test: [ 50/ 195] Loss 0.734106 Top1 80.734375 Top5 95.226562
# 2018-12-13 17:33:33,762 - Test: [ 100/ 195] Loss 0.858832 Top1 77.910156 Top5 93.960938
# 2018-12-13 17:33:40,901 - Test: [ 150/ 195] Loss 0.981425 Top1 75.471354 Top5 92.401042
# 2018-12-13 17:33:47,076 - ==> Top1: 74.426 Top5: 91.962 Loss: 1.025
version: 1
pruners:
fc_pruner:
class: AutomatedGradualPruner
initial_sparsity : 0.05
final_sparsity: 0.70
weights: module.fc.weight
filter_pruner:
class: L1RankedStructureParameterPruner_AGP
initial_sparsity : 0.05
final_sparsity: 0.50
group_type: Filters
weights: [module.layer1.0.conv1.weight,
module.layer1.1.conv1.weight,
module.layer1.2.conv1.weight,
module.layer2.0.conv1.weight,
module.layer2.1.conv1.weight,
module.layer2.2.conv1.weight,
module.layer2.3.conv1.weight,
module.layer3.0.conv1.weight,
module.layer3.1.conv1.weight,
module.layer3.2.conv1.weight,
module.layer3.3.conv1.weight,
module.layer3.4.conv1.weight,
module.layer3.5.conv1.weight,
module.layer4.0.conv1.weight,
module.layer4.1.conv1.weight,
module.layer4.2.conv1.weight,
module.layer1.0.conv2.weight,
module.layer1.1.conv2.weight,
module.layer1.2.conv2.weight,
module.layer2.0.conv2.weight,
module.layer2.1.conv2.weight,
module.layer2.2.conv2.weight,
module.layer2.3.conv2.weight,
module.layer3.0.conv2.weight,
module.layer3.1.conv2.weight,
module.layer3.2.conv2.weight,
module.layer3.3.conv2.weight,
module.layer3.4.conv2.weight,
module.layer3.5.conv2.weight,
module.layer4.0.conv2.weight,
module.layer4.1.conv2.weight,
module.layer4.2.conv2.weight]
fine_pruner:
class: AutomatedGradualPruner
initial_sparsity : 0.05
final_sparsity: 0.70
weights: [
module.layer4.0.conv2.weight,
module.layer4.0.conv3.weight,
module.layer4.0.downsample.0.weight,
module.layer4.1.conv1.weight,
module.layer4.1.conv2.weight,
module.layer4.1.conv3.weight,
module.layer4.2.conv1.weight,
module.layer4.2.conv2.weight,
module.layer4.2.conv3.weight]
extensions:
net_thinner:
class: 'FilterRemover'
thinning_func_str: remove_filters
arch: 'resnet50'
dataset: 'imagenet'
lr_schedulers:
pruning_lr:
class: ExponentialLR
gamma: 0.95
policies:
# - pruner:
# instance_name : fine_pruner
# starting_epoch: 0
# ending_epoch: 45
# frequency: 3
- pruner:
instance_name : filter_pruner
# args:
# mini_batch_pruning_frequency: 1
starting_epoch: 0
ending_epoch: 30
frequency: 1
- pruner:
instance_name : fc_pruner
starting_epoch: 0
ending_epoch: 30
frequency: 3
# After completeing the pruning, we perform network thinning and continue fine-tuning.
- extension:
instance_name: net_thinner
epochs: [31]
- lr_scheduler:
instance_name: pruning_lr
starting_epoch: 40
ending_epoch: 80
frequency: 1
| {
"pile_set_name": "Github"
} |
# Generated by superflore -- DO NOT EDIT
#
# Copyright Open Source Robotics Foundation
inherit ros_distro_melodic
inherit ros_superflore_generated
DESCRIPTION = "dynamically set the tf trensformation"
AUTHOR = "Ryohei Ueda <[email protected]>"
ROS_AUTHOR = "Manabu Saito <[email protected]>"
HOMEPAGE = "http://ros.org/wiki/dynamic_tf_publisher"
SECTION = "devel"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://package.xml;beginline=11;endline=11;md5=d566ef916e9dedc494f5f793a6690ba5"
ROS_CN = "jsk_common"
ROS_BPN = "dynamic_tf_publisher"
ROS_BUILD_DEPENDS = " \
dynamic-reconfigure \
geometry-msgs \
message-generation \
rospy \
tf \
"
ROS_BUILDTOOL_DEPENDS = " \
catkin-native \
"
ROS_EXPORT_DEPENDS = " \
geometry-msgs \
message-runtime \
rospy \
tf \
"
ROS_BUILDTOOL_EXPORT_DEPENDS = ""
ROS_EXEC_DEPENDS = " \
geometry-msgs \
message-runtime \
rospy \
tf \
"
# Currently informational only -- see http://www.ros.org/reps/rep-0149.html#dependency-tags.
ROS_TEST_DEPENDS = ""
DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"
# Bitbake doesn't support the "export" concept, so build them as if we needed them to build this package (even though we actually
# don't) so that they're guaranteed to have been staged should this package appear in another's DEPENDS.
DEPENDS += "${ROS_EXPORT_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}"
RDEPENDS_${PN} += "${ROS_EXEC_DEPENDS}"
# matches with: https://github.com/tork-a/jsk_common-release/archive/release/melodic/dynamic_tf_publisher/2.2.10-0.tar.gz
ROS_BRANCH ?= "branch=release/melodic/dynamic_tf_publisher"
SRC_URI = "git://github.com/tork-a/jsk_common-release;${ROS_BRANCH};protocol=https"
SRCREV = "af244c0f901953a7627e23511b863d15dae7a4e8"
S = "${WORKDIR}/git"
ROS_BUILD_TYPE = "catkin"
inherit ros_${ROS_BUILD_TYPE}
| {
"pile_set_name": "Github"
} |
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS 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. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#ifdef __cplusplus
extern "C" {
#endif
/*-----------------------------------------------------------
* Port specific definitions.
*
* The settings in this file configure FreeRTOS correctly for the
* given hardware and compiler.
*
* These settings should not be altered.
*-----------------------------------------------------------
*/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE uint32_t
#define portBASE_TYPE long
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
not need to be guarded with a critical section. */
#define portTICK_TYPE_IS_ATOMIC 1
#endif
/*-----------------------------------------------------------*/
/* Architecture specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
/*-----------------------------------------------------------*/
/* Scheduler utilities. */
#define portYIELD() \
{ \
/* Set a PendSV to request a context switch. */ \
portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT; \
\
/* Barriers are normally not required but do ensure the code is completely \
within the specified behaviour for the architecture. */ \
__asm volatile( "dsb" ); \
__asm volatile( "isb" ); \
}
#define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04 ) )
#define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) portYIELD()
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/
/* Critical section management. */
extern void vPortEnterCritical( void );
extern void vPortExitCritical( void );
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortSetBASEPRI(x)
#define portDISABLE_INTERRUPTS() vPortRaiseBASEPRI()
#define portENABLE_INTERRUPTS() vPortSetBASEPRI(0)
#define portENTER_CRITICAL() vPortEnterCritical()
#define portEXIT_CRITICAL() vPortExitCritical()
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. These are
not necessary for to use this port. They are defined so the common demo files
(which build with all the ports) will build. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
/*-----------------------------------------------------------*/
/* Tickless idle/low power functionality. */
#ifndef portSUPPRESS_TICKS_AND_SLEEP
extern void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime );
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
#endif
/*-----------------------------------------------------------*/
/* Architecture specific optimisations. */
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#endif
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
/* Generic helper function. */
__attribute__( ( always_inline ) ) static inline uint8_t ucPortCountLeadingZeros( uint32_t ulBitmap )
{
uint8_t ucReturn;
__asm volatile ( "clz %0, %1" : "=r" ( ucReturn ) : "r" ( ulBitmap ) );
return ucReturn;
}
/* Check the configuration. */
#if( configMAX_PRIORITIES > 32 )
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
#endif
/* Store/clear the ready priorities in a bit map. */
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) )
/*-----------------------------------------------------------*/
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31UL - ( uint32_t ) ucPortCountLeadingZeros( ( uxReadyPriorities ) ) )
#endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
/*-----------------------------------------------------------*/
#ifdef configASSERT
void vPortValidateInterruptPriority( void );
#define portASSERT_IF_INTERRUPT_PRIORITY_INVALID() vPortValidateInterruptPriority()
#endif
/* portNOP() is not required by this port. */
#define portNOP()
#define portINLINE __inline
#ifndef portFORCE_INLINE
#define portFORCE_INLINE inline __attribute__(( always_inline))
#endif
portFORCE_INLINE static BaseType_t xPortIsInsideInterrupt( void )
{
uint32_t ulCurrentInterrupt;
BaseType_t xReturn;
/* Obtain the number of the currently executing interrupt. */
__asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) );
if( ulCurrentInterrupt == 0 )
{
xReturn = pdFALSE;
}
else
{
xReturn = pdTRUE;
}
return xReturn;
}
/*-----------------------------------------------------------*/
portFORCE_INLINE static void vPortRaiseBASEPRI( void )
{
uint32_t ulNewBASEPRI;
__asm volatile
(
" mov %0, %1 \n" \
" msr basepri, %0 \n" \
" isb \n" \
" dsb \n" \
:"=r" (ulNewBASEPRI) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}
/*-----------------------------------------------------------*/
portFORCE_INLINE static uint32_t ulPortRaiseBASEPRI( void )
{
uint32_t ulOriginalBASEPRI, ulNewBASEPRI;
__asm volatile
(
" mrs %0, basepri \n" \
" mov %1, %2 \n" \
" msr basepri, %1 \n" \
" isb \n" \
" dsb \n" \
:"=r" (ulOriginalBASEPRI), "=r" (ulNewBASEPRI) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
/* This return will not be reached but is necessary to prevent compiler
warnings. */
return ulOriginalBASEPRI;
}
/*-----------------------------------------------------------*/
portFORCE_INLINE static void vPortSetBASEPRI( uint32_t ulNewMaskValue )
{
__asm volatile
(
" msr basepri, %0 " :: "r" ( ulNewMaskValue )
);
}
/*-----------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* PORTMACRO_H */
| {
"pile_set_name": "Github"
} |
{
"parent": "block/cube_all",
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "texture": "#all", "tintindex": 0, "cullface": "down" },
"up": { "texture": "#all", "tintindex": 0, "cullface": "up" },
"north": { "texture": "#all", "tintindex": 0, "cullface": "north" },
"south": { "texture": "#all", "tintindex": 0, "cullface": "south" },
"west": { "texture": "#all", "tintindex": 0, "cullface": "west" },
"east": { "texture": "#all", "tintindex": 0, "cullface": "east" }
}
}
]
} | {
"pile_set_name": "Github"
} |
## Cocoa.vim
This plugin is no longer actively developed. Check out [@keith/swift.vim](https://github.com/keith/swift.vim) instead.
| {
"pile_set_name": "Github"
} |
/*
EXAMPLE osmium_pub_names
Show the names and addresses of all pubs found in an OSM file.
DEMONSTRATES USE OF:
* file input
* your own handler
* access to tags
SIMPLER EXAMPLES you might want to understand first:
* osmium_read
* osmium_count
LICENSE
The code in this example file is released into the Public Domain.
*/
#include <cstdlib> // for std::exit
#include <cstring> // for std::strncmp
#include <iostream> // for std::cout, std::cerr
// Allow any format of input files (XML, PBF, ...)
#include <osmium/io/any_input.hpp>
// We want to use the handler interface
#include <osmium/handler.hpp>
// For osmium::apply()
#include <osmium/visitor.hpp>
class NamesHandler : public osmium::handler::Handler {
void output_pubs(const osmium::OSMObject& object) {
const osmium::TagList& tags = object.tags();
if (tags.has_tag("amenity", "pub")) {
// Print name of the pub if it is set.
const char* name = tags["name"];
if (name) {
std::cout << name << "\n";
} else {
std::cout << "pub with unknown name\n";
}
// Iterate over all tags finding those which start with "addr:"
// and print them.
for (const osmium::Tag& tag : tags) {
if (!std::strncmp(tag.key(), "addr:", 5)) {
std::cout << " " << tag.key() << ": " << tag.value() << "\n";
}
}
}
}
public:
// Nodes can be tagged amenity=pub.
void node(const osmium::Node& node) {
output_pubs(node);
}
// Ways can be tagged amenity=pub, too (typically buildings).
void way(const osmium::Way& way) {
output_pubs(way);
}
}; // class NamesHandler
int main(int argc, char* argv[]) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " OSMFILE\n";
std::exit(1);
}
// Construct the handler defined above
NamesHandler names_handler;
// Initialize the reader with the filename from the command line and
// tell it to only read nodes and ways. We are ignoring multipolygon
// relations in this simple example.
osmium::io::Reader reader{argv[1], osmium::osm_entity_bits::node | osmium::osm_entity_bits::way};
// Apply input data to our own handler
osmium::apply(reader, names_handler);
}
| {
"pile_set_name": "Github"
} |
/*
*
* Copyright 2014 gRPC 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
*
* 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.
*
*/
// Package codes defines the canonical error codes used by gRPC. It is
// consistent across various languages.
package codes // import "google.golang.org/grpc/codes"
import (
"fmt"
"strconv"
)
// A Code is an unsigned 32-bit error code as defined in the gRPC spec.
type Code uint32
const (
// OK is returned on success.
OK Code = 0
// Canceled indicates the operation was canceled (typically by the caller).
//
// The gRPC framework will generate this error code when cancellation
// is requested.
Canceled Code = 1
// Unknown error. An example of where this error may be returned is
// if a Status value received from another address space belongs to
// an error-space that is not known in this address space. Also
// errors raised by APIs that do not return enough error information
// may be converted to this error.
//
// The gRPC framework will generate this error code in the above two
// mentioned cases.
Unknown Code = 2
// InvalidArgument indicates client specified an invalid argument.
// Note that this differs from FailedPrecondition. It indicates arguments
// that are problematic regardless of the state of the system
// (e.g., a malformed file name).
//
// This error code will not be generated by the gRPC framework.
InvalidArgument Code = 3
// DeadlineExceeded means operation expired before completion.
// For operations that change the state of the system, this error may be
// returned even if the operation has completed successfully. For
// example, a successful response from a server could have been delayed
// long enough for the deadline to expire.
//
// The gRPC framework will generate this error code when the deadline is
// exceeded.
DeadlineExceeded Code = 4
// NotFound means some requested entity (e.g., file or directory) was
// not found.
//
// This error code will not be generated by the gRPC framework.
NotFound Code = 5
// AlreadyExists means an attempt to create an entity failed because one
// already exists.
//
// This error code will not be generated by the gRPC framework.
AlreadyExists Code = 6
// PermissionDenied indicates the caller does not have permission to
// execute the specified operation. It must not be used for rejections
// caused by exhausting some resource (use ResourceExhausted
// instead for those errors). It must not be
// used if the caller cannot be identified (use Unauthenticated
// instead for those errors).
//
// This error code will not be generated by the gRPC core framework,
// but expect authentication middleware to use it.
PermissionDenied Code = 7
// ResourceExhausted indicates some resource has been exhausted, perhaps
// a per-user quota, or perhaps the entire file system is out of space.
//
// This error code will be generated by the gRPC framework in
// out-of-memory and server overload situations, or when a message is
// larger than the configured maximum size.
ResourceExhausted Code = 8
// FailedPrecondition indicates operation was rejected because the
// system is not in a state required for the operation's execution.
// For example, directory to be deleted may be non-empty, an rmdir
// operation is applied to a non-directory, etc.
//
// A litmus test that may help a service implementor in deciding
// between FailedPrecondition, Aborted, and Unavailable:
// (a) Use Unavailable if the client can retry just the failing call.
// (b) Use Aborted if the client should retry at a higher-level
// (e.g., restarting a read-modify-write sequence).
// (c) Use FailedPrecondition if the client should not retry until
// the system state has been explicitly fixed. E.g., if an "rmdir"
// fails because the directory is non-empty, FailedPrecondition
// should be returned since the client should not retry unless
// they have first fixed up the directory by deleting files from it.
// (d) Use FailedPrecondition if the client performs conditional
// REST Get/Update/Delete on a resource and the resource on the
// server does not match the condition. E.g., conflicting
// read-modify-write on the same resource.
//
// This error code will not be generated by the gRPC framework.
FailedPrecondition Code = 9
// Aborted indicates the operation was aborted, typically due to a
// concurrency issue like sequencer check failures, transaction aborts,
// etc.
//
// See litmus test above for deciding between FailedPrecondition,
// Aborted, and Unavailable.
//
// This error code will not be generated by the gRPC framework.
Aborted Code = 10
// OutOfRange means operation was attempted past the valid range.
// E.g., seeking or reading past end of file.
//
// Unlike InvalidArgument, this error indicates a problem that may
// be fixed if the system state changes. For example, a 32-bit file
// system will generate InvalidArgument if asked to read at an
// offset that is not in the range [0,2^32-1], but it will generate
// OutOfRange if asked to read from an offset past the current
// file size.
//
// There is a fair bit of overlap between FailedPrecondition and
// OutOfRange. We recommend using OutOfRange (the more specific
// error) when it applies so that callers who are iterating through
// a space can easily look for an OutOfRange error to detect when
// they are done.
//
// This error code will not be generated by the gRPC framework.
OutOfRange Code = 11
// Unimplemented indicates operation is not implemented or not
// supported/enabled in this service.
//
// This error code will be generated by the gRPC framework. Most
// commonly, you will see this error code when a method implementation
// is missing on the server. It can also be generated for unknown
// compression algorithms or a disagreement as to whether an RPC should
// be streaming.
Unimplemented Code = 12
// Internal errors. Means some invariants expected by underlying
// system has been broken. If you see one of these errors,
// something is very broken.
//
// This error code will be generated by the gRPC framework in several
// internal error conditions.
Internal Code = 13
// Unavailable indicates the service is currently unavailable.
// This is a most likely a transient condition and may be corrected
// by retrying with a backoff. Note that it is not always safe to retry
// non-idempotent operations.
//
// See litmus test above for deciding between FailedPrecondition,
// Aborted, and Unavailable.
//
// This error code will be generated by the gRPC framework during
// abrupt shutdown of a server process or network connection.
Unavailable Code = 14
// DataLoss indicates unrecoverable data loss or corruption.
//
// This error code will not be generated by the gRPC framework.
DataLoss Code = 15
// Unauthenticated indicates the request does not have valid
// authentication credentials for the operation.
//
// The gRPC framework will generate this error code when the
// authentication metadata is invalid or a Credentials callback fails,
// but also expect authentication middleware to generate it.
Unauthenticated Code = 16
_maxCode = 17
)
var strToCode = map[string]Code{
`"OK"`: OK,
`"CANCELLED"`:/* [sic] */ Canceled,
`"UNKNOWN"`: Unknown,
`"INVALID_ARGUMENT"`: InvalidArgument,
`"DEADLINE_EXCEEDED"`: DeadlineExceeded,
`"NOT_FOUND"`: NotFound,
`"ALREADY_EXISTS"`: AlreadyExists,
`"PERMISSION_DENIED"`: PermissionDenied,
`"RESOURCE_EXHAUSTED"`: ResourceExhausted,
`"FAILED_PRECONDITION"`: FailedPrecondition,
`"ABORTED"`: Aborted,
`"OUT_OF_RANGE"`: OutOfRange,
`"UNIMPLEMENTED"`: Unimplemented,
`"INTERNAL"`: Internal,
`"UNAVAILABLE"`: Unavailable,
`"DATA_LOSS"`: DataLoss,
`"UNAUTHENTICATED"`: Unauthenticated,
}
// UnmarshalJSON unmarshals b into the Code.
func (c *Code) UnmarshalJSON(b []byte) error {
// From json.Unmarshaler: By convention, to approximate the behavior of
// Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as
// a no-op.
if string(b) == "null" {
return nil
}
if c == nil {
return fmt.Errorf("nil receiver passed to UnmarshalJSON")
}
if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil {
if ci >= _maxCode {
return fmt.Errorf("invalid code: %q", ci)
}
*c = Code(ci)
return nil
}
if jc, ok := strToCode[string(b)]; ok {
*c = jc
return nil
}
return fmt.Errorf("invalid code: %q", string(b))
}
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: c708c71dd76aca548a73cd2130d0e6b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
---
layout: tutorial
redirect_from: "/edge/custom_boot.html"
file_name: custom_boot
order:
---
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="section-1">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-1">¶</a>
</div>
<p>If you want to customize your jasmine environment you can customize your boot.js file.</p>
<p>The core of <code>boot.js</code> should stay the same, but you can add new things to the interface or configure things by changing this file.</p>
</td>
<td class="code">
<div class="highlight">
<pre><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">jasmine</span> <span class="o">=</span> <span class="nx">jasmineRequire</span><span class="p">.</span><span class="nx">core</span><span class="p">(</span><span class="nx">jasmineRequire</span><span class="p">);</span>
<span class="nx">jasmineRequire</span><span class="p">.</span><span class="nx">html</span><span class="p">(</span><span class="nx">jasmine</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">env</span> <span class="o">=</span> <span class="nx">jasmine</span><span class="p">.</span><span class="nx">getEnv</span><span class="p">();</span></pre>
</div>
</td>
</tr>
<tr id="section-Customizing_the_interface">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-Customizing_the_interface">¶</a>
</div>
<h2>Customizing the interface</h2>
<p>Once the core jasmine interface has been loaded, you can add new functions or rewrite existing functions.</p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="kd">var</span> <span class="nx">jasmineInterface</span> <span class="o">=</span> <span class="nx">jasmineRequire</span><span class="p">.</span><span class="kr">interface</span><span class="p">(</span><span class="nx">jasmine</span><span class="p">,</span> <span class="nx">env</span><span class="p">);</span></pre>
</div>
</td>
</tr>
<tr id="section-3">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p>Here, we're adding some aliases so <code>before</code> is the same as <code>beforeEach</code></p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">before</span> <span class="o">=</span> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">beforeEach</span><span class="p">;</span></pre>
</div>
</td>
</tr>
<tr id="section-4">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p><code>after</code> is the same as <code>afterEach</code></p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">after</span> <span class="o">=</span> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">afterEach</span><span class="p">;</span></pre>
</div>
</td>
</tr>
<tr id="section-5">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>and <code>context</code> is the same as <code>describe</code></p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">context</span> <span class="o">=</span> <span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">describe</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nb">window</span> <span class="o">==</span> <span class="s2">"undefined"</span> <span class="o">&&</span> <span class="k">typeof</span> <span class="nx">exports</span> <span class="o">==</span> <span class="s2">"object"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">extend</span><span class="p">(</span><span class="nx">exports</span><span class="p">,</span> <span class="nx">jasmineInterface</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">extend</span><span class="p">(</span><span class="nb">window</span><span class="p">,</span> <span class="nx">jasmineInterface</span><span class="p">);</span>
<span class="p">}</span></pre>
</div>
</td>
</tr>
<tr id="section-Adding_a_custom_reporter">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-Adding_a_custom_reporter">¶</a>
</div>
<h2>Adding a custom reporter</h2>
<p>You can also add your own reporter either in addition to or in place of the <code>jsApiReporter</code> and <code>htmlReporter</code></p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="nx">env</span><span class="p">.</span><span class="nx">addReporter</span><span class="p">(</span><span class="nx">jasmineInterface</span><span class="p">.</span><span class="nx">jsApiReporter</span><span class="p">);</span></pre>
</div>
</td>
</tr>
<tr id="section-7">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-7">¶</a>
</div>
<p>You can also customize how specs are filtered from the current run by changing the <code>env.specFilter</code> function</p>
<p>Alternately, specs to be run may also be specified after the tests have been parsed by passing an array of suite
or spec IDs to the execute function. These IDs can be gleaned by traversing the tree of parsed tests accessible
via env.topSuite().</p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="kd">var</span> <span class="nx">specFilter</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">jasmine</span><span class="p">.</span><span class="nx">HtmlSpecFilter</span><span class="p">({</span>
<span class="nx">filterString</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nx">queryString</span><span class="p">.</span><span class="nx">getParam</span><span class="p">(</span><span class="s2">"spec"</span><span class="p">);</span> <span class="p">}</span>
<span class="p">});</span>
<span class="nx">env</span><span class="p">.</span><span class="nx">specFilter</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">spec</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="nx">specFilter</span><span class="p">.</span><span class="nx">matches</span><span class="p">(</span><span class="nx">spec</span><span class="p">.</span><span class="nx">getFullName</span><span class="p">());</span>
<span class="p">};</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">setTimeout</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">setTimeout</span><span class="p">;</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">setInterval</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">setInterval</span><span class="p">;</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">clearTimeout</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">clearTimeout</span><span class="p">;</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">clearInterval</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">clearInterval</span><span class="p">;</span></pre>
</div>
</td>
</tr>
<tr id="section-8">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-8">¶</a>
</div>
<p>By default, Jasmine will begin execution when the <code>onload</code> event is triggered in the browser.
Replace this portion, if you want to wait for something else before calling <code>execute</code></p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="kd">var</span> <span class="nx">currentWindowOnload</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">onload</span><span class="p">;</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">onload</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">currentWindowOnload</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">currentWindowOnload</span><span class="p">();</span>
<span class="p">}</span>
<span class="nx">env</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="nx">env</span><span class="p">.</span><span class="nx">topSuite</span><span class="p">().</span><span class="nx">id</span><span class="p">);</span>
<span class="p">};</span></pre>
</div>
</td>
</tr>
<tr id="section-9">
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-9">¶</a>
</div>
<p>Helper function to add the Jasmine public interface to the correct object.</p>
</td>
<td class="code">
<div class="highlight">
<pre> <span class="kd">function</span> <span class="nx">extend</span><span class="p">(</span><span class="nx">destination</span><span class="p">,</span> <span class="nx">source</span><span class="p">)</span> <span class="p">{</span>
<span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">property</span> <span class="k">in</span> <span class="nx">source</span><span class="p">)</span> <span class="nx">destination</span><span class="p">[</span><span class="nx">property</span><span class="p">]</span> <span class="o">=</span> <span class="nx">source</span><span class="p">[</span><span class="nx">property</span><span class="p">];</span>
<span class="k">return</span> <span class="nx">destination</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}());</span></pre>
</div>
</td>
</tr>
</tbody>
</table>
| {
"pile_set_name": "Github"
} |
import tests.periodicities.period_test as per
per.buildModel((24 , 'T' , 100));
| {
"pile_set_name": "Github"
} |
@import "src/test/resources/ro/isdc/wro/extensions/processor/bourboncss/test/bourbon210/bourbon";
div.hel {
font-family: $helvetica;
}
div.georg {
font-family: $georgia;
}
div.lucid {
font-family: $lucida-grande;
}
div.mono {
font-family: $monospace;
}
div.verd {
font-family: $verdana;
}
| {
"pile_set_name": "Github"
} |
/*
Copyright 2014 The Kubernetes 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
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.
*/
package versioned
import (
"fmt"
"strconv"
"strings"
appsv1 "k8s.io/api/apps/v1"
appsv1beta1 "k8s.io/api/apps/v1beta1"
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
batchv2alpha1 "k8s.io/api/batch/v2alpha1"
"k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/kubernetes/pkg/kubectl/generate"
)
type DeploymentV1Beta1 struct{}
func (DeploymentV1Beta1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "replicas", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "serviceaccount", Required: false},
}
}
func (DeploymentV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
count, err := strconv.Atoi(params["replicas"])
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
count32 := int32(count)
deployment := extensionsv1beta1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: extensionsv1beta1.DeploymentSpec{
Replicas: &count32,
Selector: &metav1.LabelSelector{MatchLabels: labels},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
}
return &deployment, nil
}
type DeploymentAppsV1Beta1 struct{}
func (DeploymentAppsV1Beta1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "replicas", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "serviceaccount", Required: false},
}
}
func (DeploymentAppsV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
count, err := strconv.Atoi(params["replicas"])
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
count32 := int32(count)
deployment := appsv1beta1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: appsv1beta1.DeploymentSpec{
Replicas: &count32,
Selector: &metav1.LabelSelector{MatchLabels: labels},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
}
return &deployment, nil
}
type DeploymentAppsV1 struct{}
func (DeploymentAppsV1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "replicas", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "serviceaccount", Required: false},
}
}
func (DeploymentAppsV1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
count, err := strconv.Atoi(params["replicas"])
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
count32 := int32(count)
deployment := appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: appsv1.DeploymentSpec{
Replicas: &count32,
Selector: &metav1.LabelSelector{MatchLabels: labels},
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
}
return &deployment, nil
}
// getLabels returns map of labels.
func getLabels(params map[string]string, name string) (map[string]string, error) {
labelString, found := params["labels"]
var labels map[string]string
var err error
if found && len(labelString) > 0 {
labels, err = generate.ParseLabels(labelString)
if err != nil {
return nil, err
}
} else {
labels = map[string]string{
"run": name,
}
}
return labels, nil
}
// getName returns the name of newly created resource.
func getName(params map[string]string) (string, error) {
name, found := params["name"]
if !found || len(name) == 0 {
name, found = params["default-name"]
if !found || len(name) == 0 {
return "", fmt.Errorf("'name' is a required parameter")
}
}
return name, nil
}
// getParams returns map of generic parameters.
func getParams(genericParams map[string]interface{}) (map[string]string, error) {
params := map[string]string{}
for key, value := range genericParams {
strVal, isString := value.(string)
if !isString {
return nil, fmt.Errorf("expected string, saw %v for '%s'", value, key)
}
params[key] = strVal
}
return params, nil
}
// getArgs returns arguments for the container command.
func getArgs(genericParams map[string]interface{}) ([]string, error) {
args := []string{}
val, found := genericParams["args"]
if found {
var isArray bool
args, isArray = val.([]string)
if !isArray {
return nil, fmt.Errorf("expected []string, found: %v", val)
}
delete(genericParams, "args")
}
return args, nil
}
// getEnvs returns environment variables.
func getEnvs(genericParams map[string]interface{}) ([]v1.EnvVar, error) {
var envs []v1.EnvVar
envStrings, found := genericParams["env"]
if found {
if envStringArray, isArray := envStrings.([]string); isArray {
var err error
envs, err = parseEnvs(envStringArray)
if err != nil {
return nil, err
}
delete(genericParams, "env")
} else {
return nil, fmt.Errorf("expected []string, found: %v", envStrings)
}
}
return envs, nil
}
type JobV1 struct{}
func (JobV1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "leave-stdin-open", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "restart", Required: false},
{Name: "serviceaccount", Required: false},
}
}
func (JobV1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
leaveStdinOpen, err := generate.GetBool(params, "leave-stdin-open", false)
if err != nil {
return nil, err
}
podSpec.Containers[0].StdinOnce = !leaveStdinOpen && podSpec.Containers[0].Stdin
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
restartPolicy := v1.RestartPolicy(params["restart"])
if len(restartPolicy) == 0 {
restartPolicy = v1.RestartPolicyNever
}
podSpec.RestartPolicy = restartPolicy
job := batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
}
return &job, nil
}
type CronJobV2Alpha1 struct{}
func (CronJobV2Alpha1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "leave-stdin-open", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "restart", Required: false},
{Name: "schedule", Required: true},
{Name: "serviceaccount", Required: false},
}
}
func (CronJobV2Alpha1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
leaveStdinOpen, err := generate.GetBool(params, "leave-stdin-open", false)
if err != nil {
return nil, err
}
podSpec.Containers[0].StdinOnce = !leaveStdinOpen && podSpec.Containers[0].Stdin
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
restartPolicy := v1.RestartPolicy(params["restart"])
if len(restartPolicy) == 0 {
restartPolicy = v1.RestartPolicyNever
}
podSpec.RestartPolicy = restartPolicy
cronJob := batchv2alpha1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: batchv2alpha1.CronJobSpec{
Schedule: params["schedule"],
ConcurrencyPolicy: batchv2alpha1.AllowConcurrent,
JobTemplate: batchv2alpha1.JobTemplateSpec{
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
},
},
}
return &cronJob, nil
}
type CronJobV1Beta1 struct{}
func (CronJobV1Beta1) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "leave-stdin-open", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "restart", Required: false},
{Name: "schedule", Required: true},
{Name: "serviceaccount", Required: false},
}
}
func (CronJobV1Beta1) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
leaveStdinOpen, err := generate.GetBool(params, "leave-stdin-open", false)
if err != nil {
return nil, err
}
podSpec.Containers[0].StdinOnce = !leaveStdinOpen && podSpec.Containers[0].Stdin
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
restartPolicy := v1.RestartPolicy(params["restart"])
if len(restartPolicy) == 0 {
restartPolicy = v1.RestartPolicyNever
}
podSpec.RestartPolicy = restartPolicy
cronJob := batchv1beta1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: batchv1beta1.CronJobSpec{
Schedule: params["schedule"],
ConcurrencyPolicy: batchv1beta1.AllowConcurrent,
JobTemplate: batchv1beta1.JobTemplateSpec{
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
},
},
}
return &cronJob, nil
}
type BasicReplicationController struct{}
func (BasicReplicationController) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "replicas", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "tty", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "serviceaccount", Required: false},
}
}
// populateResourceListV1 takes strings of form <resourceName1>=<value1>,<resourceName1>=<value2>
// and returns ResourceList.
func populateResourceListV1(spec string) (v1.ResourceList, error) {
// empty input gets a nil response to preserve generator test expected behaviors
if spec == "" {
return nil, nil
}
result := v1.ResourceList{}
resourceStatements := strings.Split(spec, ",")
for _, resourceStatement := range resourceStatements {
parts := strings.Split(resourceStatement, "=")
if len(parts) != 2 {
return nil, fmt.Errorf("Invalid argument syntax %v, expected <resource>=<value>", resourceStatement)
}
resourceName := v1.ResourceName(parts[0])
resourceQuantity, err := resource.ParseQuantity(parts[1])
if err != nil {
return nil, err
}
result[resourceName] = resourceQuantity
}
return result, nil
}
// HandleResourceRequirementsV1 parses the limits and requests parameters if specified
// and returns ResourceRequirements.
func HandleResourceRequirementsV1(params map[string]string) (v1.ResourceRequirements, error) {
result := v1.ResourceRequirements{}
limits, err := populateResourceListV1(params["limits"])
if err != nil {
return result, err
}
result.Limits = limits
requests, err := populateResourceListV1(params["requests"])
if err != nil {
return result, err
}
result.Requests = requests
return result, nil
}
// makePodSpec returns PodSpec filled with passed parameters.
func makePodSpec(params map[string]string, name string) (*v1.PodSpec, error) {
stdin, err := generate.GetBool(params, "stdin", false)
if err != nil {
return nil, err
}
tty, err := generate.GetBool(params, "tty", false)
if err != nil {
return nil, err
}
resourceRequirements, err := HandleResourceRequirementsV1(params)
if err != nil {
return nil, err
}
spec := v1.PodSpec{
ServiceAccountName: params["serviceaccount"],
Containers: []v1.Container{
{
Name: name,
Image: params["image"],
Stdin: stdin,
TTY: tty,
Resources: resourceRequirements,
},
},
}
return &spec, nil
}
func (BasicReplicationController) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
count, err := strconv.Atoi(params["replicas"])
if err != nil {
return nil, err
}
podSpec, err := makePodSpec(params, name)
if err != nil {
return nil, err
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, podSpec); err != nil {
return nil, err
}
if err := updatePodPorts(params, podSpec); err != nil {
return nil, err
}
count32 := int32(count)
controller := v1.ReplicationController{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: v1.ReplicationControllerSpec{
Replicas: &count32,
Selector: labels,
Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: *podSpec,
},
},
}
return &controller, nil
}
// updatePodContainers updates PodSpec.Containers with passed parameters.
func updatePodContainers(params map[string]string, args []string, envs []v1.EnvVar, imagePullPolicy v1.PullPolicy, podSpec *v1.PodSpec) error {
if len(args) > 0 {
command, err := generate.GetBool(params, "command", false)
if err != nil {
return err
}
if command {
podSpec.Containers[0].Command = args
} else {
podSpec.Containers[0].Args = args
}
}
if len(envs) > 0 {
podSpec.Containers[0].Env = envs
}
if len(imagePullPolicy) > 0 {
// imagePullPolicy should be valid here since we have verified it before.
podSpec.Containers[0].ImagePullPolicy = imagePullPolicy
}
return nil
}
// updatePodContainers updates PodSpec.Containers.Ports with passed parameters.
func updatePodPorts(params map[string]string, podSpec *v1.PodSpec) (err error) {
port := -1
hostPort := -1
if len(params["port"]) > 0 {
port, err = strconv.Atoi(params["port"])
if err != nil {
return err
}
}
if len(params["hostport"]) > 0 {
hostPort, err = strconv.Atoi(params["hostport"])
if err != nil {
return err
}
if hostPort > 0 && port < 0 {
return fmt.Errorf("--hostport requires --port to be specified")
}
}
// Don't include the port if it was not specified.
if len(params["port"]) > 0 {
podSpec.Containers[0].Ports = []v1.ContainerPort{
{
ContainerPort: int32(port),
},
}
if hostPort > 0 {
podSpec.Containers[0].Ports[0].HostPort = int32(hostPort)
}
}
return nil
}
type BasicPod struct{}
func (BasicPod) ParamNames() []generate.GeneratorParam {
return []generate.GeneratorParam{
{Name: "labels", Required: false},
{Name: "default-name", Required: false},
{Name: "name", Required: true},
{Name: "image", Required: true},
{Name: "image-pull-policy", Required: false},
{Name: "port", Required: false},
{Name: "hostport", Required: false},
{Name: "stdin", Required: false},
{Name: "leave-stdin-open", Required: false},
{Name: "tty", Required: false},
{Name: "restart", Required: false},
{Name: "command", Required: false},
{Name: "args", Required: false},
{Name: "env", Required: false},
{Name: "requests", Required: false},
{Name: "limits", Required: false},
{Name: "serviceaccount", Required: false},
}
}
func (BasicPod) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
args, err := getArgs(genericParams)
if err != nil {
return nil, err
}
envs, err := getEnvs(genericParams)
if err != nil {
return nil, err
}
params, err := getParams(genericParams)
if err != nil {
return nil, err
}
name, err := getName(params)
if err != nil {
return nil, err
}
labels, err := getLabels(params, name)
if err != nil {
return nil, err
}
stdin, err := generate.GetBool(params, "stdin", false)
if err != nil {
return nil, err
}
leaveStdinOpen, err := generate.GetBool(params, "leave-stdin-open", false)
if err != nil {
return nil, err
}
tty, err := generate.GetBool(params, "tty", false)
if err != nil {
return nil, err
}
resourceRequirements, err := HandleResourceRequirementsV1(params)
if err != nil {
return nil, err
}
restartPolicy := v1.RestartPolicy(params["restart"])
if len(restartPolicy) == 0 {
restartPolicy = v1.RestartPolicyAlways
}
pod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: v1.PodSpec{
ServiceAccountName: params["serviceaccount"],
Containers: []v1.Container{
{
Name: name,
Image: params["image"],
Stdin: stdin,
StdinOnce: !leaveStdinOpen && stdin,
TTY: tty,
Resources: resourceRequirements,
},
},
DNSPolicy: v1.DNSClusterFirst,
RestartPolicy: restartPolicy,
},
}
imagePullPolicy := v1.PullPolicy(params["image-pull-policy"])
if err = updatePodContainers(params, args, envs, imagePullPolicy, &pod.Spec); err != nil {
return nil, err
}
if err := updatePodPorts(params, &pod.Spec); err != nil {
return nil, err
}
return &pod, nil
}
// parseEnvs converts string into EnvVar objects.
func parseEnvs(envArray []string) ([]v1.EnvVar, error) {
envs := make([]v1.EnvVar, 0, len(envArray))
for _, env := range envArray {
pos := strings.Index(env, "=")
if pos == -1 {
return nil, fmt.Errorf("invalid env: %v", env)
}
name := env[:pos]
value := env[pos+1:]
if len(name) == 0 {
return nil, fmt.Errorf("invalid env: %v", env)
}
if len(validation.IsEnvVarName(name)) != 0 {
return nil, fmt.Errorf("invalid env: %v", env)
}
envVar := v1.EnvVar{Name: name, Value: value}
envs = append(envs, envVar)
}
return envs, nil
}
| {
"pile_set_name": "Github"
} |
/*
* /MathJax/jax/output/HTML-CSS/fonts/STIX/General/Regular/GeometricShapes.js
*
* Copyright (c) 2012 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Insert(MathJax.OutputJax["HTML-CSS"].FONTDATA.FONTS.STIXGeneral,{9632:[662,158,910,45,865],9633:[662,158,910,45,865],9634:[662,158,910,45,865],9635:[662,158,910,45,865],9636:[662,158,910,45,865],9637:[662,158,910,45,865],9638:[662,158,910,45,865],9639:[662,158,910,45,865],9640:[662,158,910,45,865],9641:[662,158,910,45,865],9642:[460,-40,484,32,452],9643:[460,-40,484,32,452],9644:[469,11,1020,38,982],9645:[469,11,1020,38,982],9646:[724,220,560,40,520],9647:[724,220,560,40,520],9648:[514,11,1140,28,1112],9649:[514,11,1140,29,1111],9650:[811,127,1145,35,1110],9652:[553,-28,660,27,632],9653:[553,-28,660,27,632],9654:[790,285,1043,70,1008],9655:[791,284,1043,70,1008],9656:[556,49,660,80,605],9658:[555,50,930,65,885],9659:[555,50,930,65,885],9660:[811,127,1145,35,1110],9662:[477,48,660,27,632],9663:[477,48,660,27,632],9664:[790,285,1043,35,973],9665:[791,284,1043,70,1008],9666:[555,50,660,55,580],9668:[555,50,930,45,865],9669:[555,50,930,45,865],9670:[744,242,1064,39,1025],9671:[744,242,1064,39,1025],9672:[744,242,1064,39,1025],9673:[623,119,842,50,792],9674:[795,289,790,45,745],9675:[623,119,842,50,792],9676:[680,176,910,29,881],9677:[680,176,910,27,884],9678:[623,119,842,50,792],9679:[623,119,842,50,792],9680:[623,119,842,50,792],9681:[623,119,842,50,792],9682:[623,119,842,50,792],9683:[623,119,842,50,792],9684:[623,119,842,50,792],9685:[623,119,842,50,792],9686:[680,176,580,66,494],9687:[680,176,580,86,514],9688:[662,158,910,45,865],9689:[662,158,910,45,865],9690:[662,-252,910,45,865],9691:[252,158,910,45,865],9692:[680,-252,910,27,455],9693:[680,-252,910,455,884],9694:[252,176,910,455,884],9695:[252,176,910,26,455],9696:[680,-251,910,27,884],9697:[252,176,910,27,884],9698:[662,158,911,45,865],9699:[662,158,911,45,865],9700:[662,158,911,45,865],9701:[662,158,911,45,865],9702:[444,-59,523,70,455],9703:[662,157,910,45,865],9704:[662,157,910,45,865],9705:[662,157,910,45,865],9706:[662,157,910,45,865],9707:[662,157,910,45,865],9708:[811,127,1145,35,1110],9709:[811,127,1145,35,1110],9710:[811,127,1145,35,1110],9712:[662,158,910,45,865],9713:[662,158,910,45,865],9714:[662,158,910,45,865],9715:[662,158,910,45,865],9716:[623,119,842,50,792],9717:[623,119,842,50,792],9718:[623,119,842,50,792],9719:[623,119,842,50,792],9720:[662,158,911,45,865],9721:[662,158,911,45,865],9722:[662,158,911,45,865],9723:[580,76,746,45,701],9724:[580,76,746,45,701],9725:[513,12,601,38,563],9726:[514,11,601,38,563],9727:[662,158,911,45,865]});MathJax.Ajax.loadComplete(MathJax.OutputJax["HTML-CSS"].fontDir+"/General/Regular/GeometricShapes.js");
| {
"pile_set_name": "Github"
} |
layout(std430) buffer;
layout(FORMAT, binding=0) writeonly uniform PRECISION image2D uOutput;
layout(binding=2) readonly buffer kernel{
vec4 data[];
} uKernel;
layout(location = 3) uniform int width;
layout(location = 4) uniform int height;
//index : ky * kx, oc/4, ic/4
//kernel buffer : oc ic h w -> oc/4 ic/4 ky kx ic4 oc4
//kernel image : oc/4, ky * kx * ic/4 * ic4
layout (local_size_x = 4, local_size_y = 4, local_size_z = 1) in;
void main()
{
ivec3 pos = ivec3(gl_GlobalInvocationID);
if (pos.x < width && pos.y < height)
{
vec4 res = uKernel.data[pos.x+pos.y*width];
imageStore(uOutput, ivec2(pos.x, pos.y), res);
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2013-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.data.cassandra.core.cql.keyspace;
import java.util.List;
import java.util.Map;
import com.datastax.oss.driver.api.core.CqlIdentifier;
/**
* Describes a table.
*
* @author Matthew T. Adams
* @author Alex Shvid
*/
public interface TableDescriptor {
/**
* Returns the name of the table.
*/
CqlIdentifier getName();
/**
* Returns an unmodifiable {@link List} of {@link ColumnSpecification}s.
*/
List<ColumnSpecification> getColumns();
/**
* Returns an unmodifiable list of all partition key columns.
*/
List<ColumnSpecification> getPartitionKeyColumns();
/**
* Returns an unmodifiable list of all primary key columns that are not also partition key columns.
*/
List<ColumnSpecification> getClusteredKeyColumns();
/**
* Returns an unmodifiable list of all partition and primary key columns.
*/
List<ColumnSpecification> getPrimaryKeyColumns();
/**
* Returns an unmodifiable list of all non-key columns.
*/
List<ColumnSpecification> getNonKeyColumns();
/**
* Returns an unmodifiable {@link Map} of table options.
*/
Map<String, Object> getOptions();
}
| {
"pile_set_name": "Github"
} |
'use strict';
const Delete = require('./reducers/delete');
const Details = require('./reducers/details');
const Groups = require('./reducers/groups');
const Permissions = require('./reducers/permissions');
const Redux = require('redux');
const User = require('./reducers/user');
module.exports = Redux.createStore(
Redux.combineReducers({
delete: Delete,
details: Details,
groups: Groups,
permissions: Permissions,
user: User
})
);
| {
"pile_set_name": "Github"
} |
# CS_ARCH_SPARC, CS_MODE_BIG_ENDIAN, None
0x81,0xa8,0x0a,0x24 = fcmps %f0, %f4
0x81,0xa8,0x0a,0x44 = fcmpd %f0, %f4
0x81,0xa8,0x0a,0x64 = fcmpq %f0, %f4
0x81,0xa8,0x0a,0xa4 = fcmpes %f0, %f4
0x81,0xa8,0x0a,0xc4 = fcmped %f0, %f4
0x81,0xa8,0x0a,0xe4 = fcmpeq %f0, %f4
| {
"pile_set_name": "Github"
} |
//
// Typography
// --------------------------------------------------
// Body text
// -------------------------
p {
margin: 0 0 @baseLineHeight / 2;
}
.lead {
margin-bottom: @baseLineHeight;
font-size: @baseFontSize * 1.5;
font-weight: 200;
line-height: @baseLineHeight * 1.5;
}
// Emphasis & misc
// -------------------------
small {
font-size: 85%; // Ex: 14px base font * 85% = about 12px
}
strong {
font-weight: bold;
}
em {
font-style: italic;
}
cite {
font-style: normal;
}
// Utility classes
.muted {
color: @grayLight;
}
.text-warning {
color: @warningText;
}
.text-error {
color: @errorText;
}
.text-info {
color: @infoText;
}
.text-success {
color: @successText;
}
// Headings
// -------------------------
h1, h2, h3, h4, h5, h6 {
margin: (@baseLineHeight / 2) 0;
font-family: @headingsFontFamily;
font-weight: @headingsFontWeight;
line-height: 1;
color: @headingsColor;
text-rendering: optimizelegibility; // Fix the character spacing for headings
small {
font-weight: normal;
line-height: 1;
color: @grayLight;
}
}
h1 { font-size: 36px; line-height: 40px; }
h2 { font-size: 30px; line-height: 40px; }
h3 { font-size: 24px; line-height: 40px; }
h4 { font-size: 18px; line-height: 20px; }
h5 { font-size: 14px; line-height: 20px; }
h6 { font-size: 12px; line-height: 20px; }
h1 small { font-size: 24px; }
h2 small { font-size: 18px; }
h3 small { font-size: 14px; }
h4 small { font-size: 14px; }
// Page header
// -------------------------
.page-header {
padding-bottom: (@baseLineHeight / 2) - 1;
margin: @baseLineHeight 0 (@baseLineHeight * 1.5);
border-bottom: 1px solid @grayLighter;
}
// Lists
// --------------------------------------------------
// Unordered and Ordered lists
ul, ol {
padding: 0;
margin: 0 0 @baseLineHeight / 2 25px;
}
ul ul,
ul ol,
ol ol,
ol ul {
margin-bottom: 0;
}
li {
line-height: @baseLineHeight;
}
ul.unstyled,
ol.unstyled {
margin-left: 0;
list-style: none;
}
// Description Lists
dl {
margin-bottom: @baseLineHeight;
}
dt,
dd {
line-height: @baseLineHeight;
}
dt {
font-weight: bold;
}
dd {
margin-left: @baseLineHeight / 2;
}
// Horizontal layout (like forms)
.dl-horizontal {
.clearfix(); // Ensure dl clears floats if empty dd elements present
dt {
float: left;
width: @horizontalComponentOffset - 20;
clear: left;
text-align: right;
.text-overflow();
}
dd {
margin-left: @horizontalComponentOffset;
}
}
// MISC
// ----
// Horizontal rules
hr {
margin: @baseLineHeight 0;
border: 0;
border-top: 1px solid @hrBorder;
border-bottom: 1px solid @white;
}
// Abbreviations and acronyms
abbr[title] {
cursor: help;
border-bottom: 1px dotted @grayLight;
}
abbr.initialism {
font-size: 90%;
text-transform: uppercase;
}
// Blockquotes
blockquote {
padding: 0 0 0 15px;
margin: 0 0 @baseLineHeight;
border-left: 5px solid @grayLighter;
p {
margin-bottom: 0;
#font > .shorthand(16px,300,@baseLineHeight * 1.25);
}
small {
display: block;
line-height: @baseLineHeight;
color: @grayLight;
&:before {
content: '\2014 \00A0';
}
}
// Float right with text-align: right
&.pull-right {
float: right;
padding-right: 15px;
padding-left: 0;
border-right: 5px solid @grayLighter;
border-left: 0;
p,
small {
text-align: right;
}
small {
&:before {
content: '';
}
&:after {
content: '\00A0 \2014';
}
}
}
}
// Quotes
q:before,
q:after,
blockquote:before,
blockquote:after {
content: "";
}
// Addresses
address {
display: block;
margin-bottom: @baseLineHeight;
font-style: normal;
line-height: @baseLineHeight;
}
| {
"pile_set_name": "Github"
} |
function errService() {
return {
throwAnError: function() {
throw new Error("Error from library Code");
},
throwAnErrorFromCallback: function() {
var callback = $A.getCallback(function() {
throw Error("Error from a callback function in component library");
});
setTimeout(callback, 0);
},
throwAnErrorInPromise: function() {
var promise = new Promise(function(resolve, reject) {
reject(new Error("Error from promise in component library"));
});
}
}
}
| {
"pile_set_name": "Github"
} |
/*
Copyright 2016 The Kubernetes 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
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.
*/
package v2beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// GroupName is the group name use in this package
const GroupName = "autoscaling"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta1"}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
// Adds the list of known types to the given scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&HorizontalPodAutoscaler{},
&HorizontalPodAutoscalerList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
| {
"pile_set_name": "Github"
} |
Can't return from a void function on line 3 of input041.c
| {
"pile_set_name": "Github"
} |
/*************************************************************
* Project: NetCoreCMS *
* Web: http://dotnetcorecms.org *
* Author: OnnoRokom Software Ltd. *
* Website: www.onnorokomsoftware.com *
* Email: [email protected] *
* Copyright: OnnoRokom Software Ltd. *
* License: BSD-3-Clause *
*************************************************************/
using MediatR;
using NetCoreCMS.Framework.Core.Events.Post;
using NetCoreCMS.Framework.Core.Models;
namespace NetCoreCMS.Framework.Core.Hooks
{
public class OnPostShowHandler : IRequestHandler<OnPostShow, NccPost>
{
public NccPost Handle(OnPostShow message)
{
var post = message.Post;
return post;
}
}
}
| {
"pile_set_name": "Github"
} |
{
"price_rule": {
"id": 1213131,
"title": "BOGO",
"target_type": "line_item",
"target_selection": "all",
"allocation_method": "across",
"value_type": "percentage",
"value": -100,
"once_per_customer": true,
"usage_limit": null,
"customer_selection": "all",
"prerequisite_subtotal_range": null,
"prerequisite_shipping_price_range": null,
"starts_at": "2017-05-30T04:13:56Z",
"ends_at": null
}
} | {
"pile_set_name": "Github"
} |
{
"$schema" : "http://json-schema.org/draft-01/hyper-schema#",
"id" : "http://json-schema.org/draft-01/hyper-schema#",
"properties" : {
"links" : {
"type" : "array",
"items" : {"$ref" : "http://json-schema.org/draft-01/links#"},
"optional" : true
},
"fragmentResolution" : {
"type" : "string",
"optional" : true,
"default" : "dot-delimited"
},
"root" : {
"type" : "boolean",
"optional" : true,
"default" : false
},
"readonly" : {
"type" : "boolean",
"optional" : true,
"default" : false
},
"pathStart" : {
"type" : "string",
"optional" : true,
"format" : "uri"
},
"mediaType" : {
"type" : "string",
"optional" : true,
"format" : "media-type"
},
"alternate" : {
"type" : "array",
"items" : {"$ref" : "#"},
"optional" : true
}
},
"links" : [
{
"href" : "{$ref}",
"rel" : "full"
},
{
"href" : "{$schema}",
"rel" : "describedby"
},
{
"href" : "{id}",
"rel" : "self"
}
],
"fragmentResolution" : "dot-delimited",
"extends" : {"$ref" : "http://json-schema.org/draft-01/schema#"}
} | {
"pile_set_name": "Github"
} |
// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,amd64
package unix
import (
"syscall"
"unsafe"
)
var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
_, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fchmodat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
_, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_LINKAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mode), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PPOLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(buf) > 0 {
_p1 = unsafe.Pointer(&buf[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getcwd(buf []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func KeyctlInt(cmd int, arg2 int, arg3 int, arg4 int, arg5 int) (ret int, err error) {
r0, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
ret = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func KeyctlBuffer(cmd int, arg2 int, buf []byte, arg5 int) (ret int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(_p0), uintptr(len(buf)), uintptr(arg5), 0)
ret = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlJoin(cmd int, arg2 string) (ret int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(arg2)
if err != nil {
return
}
r0, _, e1 := Syscall(SYS_KEYCTL, uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0)
ret = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlSearch(cmd int, arg2 int, arg3 string, arg4 string, arg5 int) (ret int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(arg3)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(arg4)
if err != nil {
return
}
r0, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(arg5), 0)
ret = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlIOV(cmd int, arg2 int, payload []Iovec, arg5 int) (err error) {
var _p0 unsafe.Pointer
if len(payload) > 0 {
_p0 = unsafe.Pointer(&payload[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(_p0), uintptr(len(payload)), uintptr(arg5), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlDH(cmd int, arg2 *KeyctlDHParams, buf []byte) (ret int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(unsafe.Pointer(arg2)), uintptr(_p0), uintptr(len(buf)), 0, 0)
ret = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlRestrictKeyringByType(cmd int, arg2 int, keyType string, restriction string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(keyType)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(restriction)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func keyctlRestrictKeyring(cmd int, arg2 int) (err error) {
_, _, e1 := Syscall(SYS_KEYCTL, uintptr(cmd), uintptr(arg2), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
_, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func reboot(magic1 uint, magic2 uint, cmd int, arg string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(arg)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_REBOOT, uintptr(magic1), uintptr(magic2), uintptr(cmd), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mount(source string, target string, fstype string, flags uintptr, data *byte) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(source)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(target)
if err != nil {
return
}
var _p2 *byte
_p2, err = BytePtrFromString(fstype)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_MOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(flags), uintptr(unsafe.Pointer(data)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Acct(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_ACCT, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func AddKey(keyType string, description string, payload []byte, ringid int) (id int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(keyType)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(description)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(payload) > 0 {
_p2 = unsafe.Pointer(&payload[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_ADD_KEY, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(payload)), uintptr(ringid), 0)
id = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtimex(buf *Timex) (state int, err error) {
r0, _, e1 := Syscall(SYS_ADJTIMEX, uintptr(unsafe.Pointer(buf)), 0, 0)
state = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Capget(hdr *CapUserHeader, data *CapUserData) (err error) {
_, _, e1 := RawSyscall(SYS_CAPGET, uintptr(unsafe.Pointer(hdr)), uintptr(unsafe.Pointer(data)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Capset(hdr *CapUserHeader, data *CapUserData) (err error) {
_, _, e1 := RawSyscall(SYS_CAPSET, uintptr(unsafe.Pointer(hdr)), uintptr(unsafe.Pointer(data)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockGetres(clockid int32, res *Timespec) (err error) {
_, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockGettime(clockid int32, time *Timespec) (err error) {
_, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) {
_, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
_, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
r0, _, e1 := Syscall6(SYS_COPY_FILE_RANGE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func DeleteModule(name string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(name)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_DELETE_MODULE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(oldfd int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup3(oldfd int, newfd int, flags int) (err error) {
_, _, e1 := Syscall(SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func EpollCreate1(flag int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE1, uintptr(flag), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
_, _, e1 := RawSyscall6(SYS_EPOLL_CTL, uintptr(epfd), uintptr(op), uintptr(fd), uintptr(unsafe.Pointer(event)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Eventfd(initval uint, flags int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_EVENTFD2, uintptr(initval), uintptr(flags), 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
SyscallNoError(SYS_EXIT_GROUP, uintptr(code), 0, 0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
_, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
_, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
_, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fdatasync(fd int) (err error) {
_, _, e1 := Syscall(SYS_FDATASYNC, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(dest) > 0 {
_p1 = unsafe.Pointer(&dest[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func FinitModule(fd int, params string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(params)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FINIT_MODULE, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Flistxattr(fd int, dest []byte) (sz int, err error) {
var _p0 unsafe.Pointer
if len(dest) > 0 {
_p0 = unsafe.Pointer(&dest[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_FLISTXATTR, uintptr(fd), uintptr(_p0), uintptr(len(dest)))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Flock(fd int, how int) (err error) {
_, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fremovexattr(fd int, attr string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsetxattr(fd int, attr string, dest []byte, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(dest) > 0 {
_p1 = unsafe.Pointer(&dest[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
_, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdents(fd int, buf []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
r0, _ := RawSyscallNoError(SYS_GETPID, 0, 0, 0)
pid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
r0, _ := RawSyscallNoError(SYS_GETPPID, 0, 0, 0)
ppid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrandom(buf []byte, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Gettid() (tid int) {
r0, _ := RawSyscallNoError(SYS_GETTID, 0, 0, 0)
tid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(dest) > 0 {
_p2 = unsafe.Pointer(&dest[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func InitModule(moduleImage []byte, params string) (err error) {
var _p0 unsafe.Pointer
if len(moduleImage) > 0 {
_p0 = unsafe.Pointer(&moduleImage[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
var _p1 *byte
_p1, err = BytePtrFromString(params)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_INIT_MODULE, uintptr(_p0), uintptr(len(moduleImage)), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(pathname)
if err != nil {
return
}
r0, _, e1 := Syscall(SYS_INOTIFY_ADD_WATCH, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(mask))
watchdesc = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func InotifyInit1(flags int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT1, uintptr(flags), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func InotifyRmWatch(fd int, watchdesc uint32) (success int, err error) {
r0, _, e1 := RawSyscall(SYS_INOTIFY_RM_WATCH, uintptr(fd), uintptr(watchdesc), 0)
success = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kill(pid int, sig syscall.Signal) (err error) {
_, _, e1 := RawSyscall(SYS_KILL, uintptr(pid), uintptr(sig), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Klogctl(typ int, buf []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_SYSLOG, uintptr(typ), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lgetxattr(path string, attr string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(dest) > 0 {
_p2 = unsafe.Pointer(&dest[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_LGETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(dest)), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listxattr(path string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(dest) > 0 {
_p1 = unsafe.Pointer(&dest[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Llistxattr(path string, dest []byte) (sz int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 unsafe.Pointer
if len(dest) > 0 {
_p1 = unsafe.Pointer(&dest[0])
} else {
_p1 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lremovexattr(path string, attr string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_LREMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lsetxattr(path string, attr string, data []byte, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(data) > 0 {
_p2 = unsafe.Pointer(&data[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_LSETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func MemfdCreate(name string, flags int) (fd int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(name)
if err != nil {
return
}
r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_MKNODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
_, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) {
r0, _, e1 := Syscall6(SYS_PERF_EVENT_OPEN, uintptr(unsafe.Pointer(attr)), uintptr(pid), uintptr(cpu), uintptr(groupFd), uintptr(flags), 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func PivotRoot(newroot string, putold string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(newroot)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(putold)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_PIVOT_ROOT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func prlimit(pid int, resource int, newlimit *Rlimit, old *Rlimit) (err error) {
_, _, e1 := RawSyscall6(SYS_PRLIMIT64, uintptr(pid), uintptr(resource), uintptr(unsafe.Pointer(newlimit)), uintptr(unsafe.Pointer(old)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (err error) {
_, _, e1 := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
r0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Removexattr(path string, attr string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_RENAMEAT2, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(keyType)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(description)
if err != nil {
return
}
var _p2 *byte
_p2, err = BytePtrFromString(callback)
if err != nil {
return
}
r0, _, e1 := Syscall6(SYS_REQUEST_KEY, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(_p2)), uintptr(destRingid), 0, 0)
id = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setdomainname(p []byte) (err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_SETDOMAINNAME, uintptr(_p0), uintptr(len(p)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sethostname(p []byte) (err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_SETHOSTNAME, uintptr(_p0), uintptr(len(p)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tv *Timeval) (err error) {
_, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setns(fd int, nstype int) (err error) {
_, _, e1 := Syscall(SYS_SETNS, uintptr(fd), uintptr(nstype), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
_, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setxattr(path string, attr string, data []byte, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(attr)
if err != nil {
return
}
var _p2 unsafe.Pointer
if len(data) > 0 {
_p2 = unsafe.Pointer(&data[0])
} else {
_p2 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(_p2), uintptr(len(data)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
newfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_STATX, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(mask), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() {
SyscallNoError(SYS_SYNC, 0, 0, 0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Syncfs(fd int) (err error) {
_, _, e1 := Syscall(SYS_SYNCFS, uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sysinfo(info *Sysinfo_t) (err error) {
_, _, e1 := RawSyscall(SYS_SYSINFO, uintptr(unsafe.Pointer(info)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
r0, _, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
n = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
_, _, e1 := RawSyscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Times(tms *Tms) (ticks uintptr, err error) {
r0, _, e1 := RawSyscall(SYS_TIMES, uintptr(unsafe.Pointer(tms)), 0, 0)
ticks = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(mask int) (oldmask int) {
r0, _ := RawSyscallNoError(SYS_UMASK, uintptr(mask), 0, 0)
oldmask = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Uname(buf *Utsname) (err error) {
_, _, e1 := RawSyscall(SYS_UNAME, uintptr(unsafe.Pointer(buf)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(target string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(target)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_UMOUNT2, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unshare(flags int) (err error) {
_, _, e1 := Syscall(SYS_UNSHARE, uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func exitThread(code int) (err error) {
_, _, e1 := Syscall(SYS_EXIT, uintptr(code), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readlen(fd int, p *byte, np int) (n int, err error) {
r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writelen(fd int, p *byte, np int) (n int, err error) {
r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(np))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readv(fd int, iovs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_READV, uintptr(fd), uintptr(_p0), uintptr(len(iovs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writev(fd int, iovs []Iovec) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(SYS_WRITEV, uintptr(fd), uintptr(_p0), uintptr(len(iovs)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PREADV, uintptr(fd), uintptr(_p0), uintptr(len(iovs)), uintptr(offs_l), uintptr(offs_h), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PWRITEV, uintptr(fd), uintptr(_p0), uintptr(len(iovs)), uintptr(offs_l), uintptr(offs_h), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func preadv2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PREADV2, uintptr(fd), uintptr(_p0), uintptr(len(iovs)), uintptr(offs_l), uintptr(offs_h), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pwritev2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) {
var _p0 unsafe.Pointer
if len(iovs) > 0 {
_p0 = unsafe.Pointer(&iovs[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PWRITEV2, uintptr(fd), uintptr(_p0), uintptr(len(iovs)), uintptr(offs_l), uintptr(offs_h), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
_, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, advice int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(advice))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
_, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
var _p0 unsafe.Pointer
if len(b) > 0 {
_p0 = unsafe.Pointer(&b[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
_, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func faccessat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func nameToHandleAt(dirFD int, pathname string, fh *fileHandle, mountID *_C_int, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(pathname)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_NAME_TO_HANDLE_AT, uintptr(dirFD), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(fh)), uintptr(unsafe.Pointer(mountID)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func openByHandleAt(mountFD int, fh *fileHandle, flags int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_OPEN_BY_HANDLE_AT, uintptr(mountFD), uintptr(unsafe.Pointer(fh)), uintptr(flags))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(oldfd int, newfd int) (err error) {
_, _, e1 := Syscall(SYS_DUP2, uintptr(oldfd), uintptr(newfd), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func EpollCreate(size int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_EPOLL_CREATE, uintptr(size), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
var _p0 unsafe.Pointer
if len(events) > 0 {
_p0 = unsafe.Pointer(&events[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
_, _, e1 := Syscall6(SYS_FADVISE64, uintptr(fd), uintptr(offset), uintptr(length), uintptr(advice), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
_, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstat(fd int, stat *Stat_t) (err error) {
_, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_NEWFSTATAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fstatfs(fd int, buf *Statfs_t) (err error) {
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
_, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
r0, _ := RawSyscallNoError(SYS_GETEGID, 0, 0, 0)
egid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (euid int) {
r0, _ := RawSyscallNoError(SYS_GETEUID, 0, 0, 0)
euid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
r0, _ := RawSyscallNoError(SYS_GETGID, 0, 0, 0)
gid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(resource int, rlim *Rlimit) (err error) {
_, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
r0, _ := RawSyscallNoError(SYS_GETUID, 0, 0, 0)
uid = int(r0)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func inotifyInit() (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ioperm(from int, num int, on int) (err error) {
_, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Iopl(level int) (err error) {
_, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, n int) (err error) {
_, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pause() (err error) {
_, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(oldpath)
if err != nil {
return
}
var _p1 *byte
_p1, err = BytePtrFromString(newpath)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (off int64, err error) {
r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
off = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
written = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setfsgid(gid int) (prev int, err error) {
r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
prev = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setfsuid(uid int) (prev int, err error) {
r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
prev = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setresgid(rgid int, egid int, sgid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setresuid(ruid int, euid int, suid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setrlimit(resource int, rlim *Rlimit) (err error) {
_, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
_, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(fd int, how int) (err error) {
_, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
n = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Statfs(path string, buf *Statfs_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
_, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ustat(dev int, ubuf *Ustat_t) (err error) {
_, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
_, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
_, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(n int, list *_Gid_t) (nn int, err error) {
r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
nn = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(n int, list *_Gid_t) (err error) {
_, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
_, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
_, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
_, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
var _p0 unsafe.Pointer
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
} else {
_p0 = unsafe.Pointer(&_zero)
}
_, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
xaddr = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Utime(path string, buf *Utimbuf) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, times *[2]Timeval) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
if err != nil {
return
}
_, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe(p *[2]_C_int) (err error) {
_, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe2(p *[2]_C_int, flags int) (err error) {
_, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(cmdline)
if err != nil {
return
}
_, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
| {
"pile_set_name": "Github"
} |
# Start with data to build your app
[When you make a full stack Rust app, your workflow will be similar to this.](https://github.com/steadylearner/Rust-Full-Stack)
1. Install Postgresql or another databases.
2. Test first with its CLI commands(psql).
3. Use ORM(Diesel etc) instead of them. Then, include R2D2 for connection reuse.
4. Make Rust web server with routes.
5. Use a template engine such as Tera to show visual results.
6. Substitute it with Yew or another single page app if necessary.
## Rust Diesel
1. [Starter for CRUD Structure](http://diesel.rs/guides/getting-started/)
2. [Documentation](http://docs.diesel.rs/diesel/index.html)
3. [Blog Example with Rocket Rust](https://notryanb.github.io/rust-blog-series-1.html)
4. [Refer to the example with Warp](https://github.com/steadylearner/Rust-Full-Stack/blob/master/warp/database/2.%20with_db_pool/src/models/post.rs)
## Postgresql
1. [Official Documentation](https://www.postgresql.org/docs/current/static/tutorial-sql.html)
2. [Install it in your machine](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)
3. [You can also Use Docker or AWS etc instead to deploy or test locally.](https://www.steadylearner.com/blog/read/Docker)
## Connect to Postgesql
```console
// 1. Install Postgresql on Linux.
// 2. Login to psqL.
// 3. Use it to connect to postgresql.
// 4. Create another user if you want.
$sudo apt update && $sudo apt install postgresql postgresql-contrib
$sudo -i -u postgres
$psql
$sudo -u postgres createuser --interactive
// Save some aliases with the commands used here at .bashrc.
$vim ~/.bashrc
alias pgres="sudo -i -u postgres psql"
alias createpostgresuser="sudo -u postgres createuser --interactive"
$source ~/.bashrc
```
## Use it with SQL commands
You have to almost always use ; at the end you use it.
```sql
CREATE USER owner1 WITH PASSWORD 'password1';
ALTER USER my_user_name WITH PASSWORD 'my_secure_password';
CREATE DATABASE demo_db1 OWNER owner1;
```
Refer to these commands from psql console.
1. `\h` to show SQL
2. `\?` for psql commands
3. `\password` to edit password
4. `\du` to list user
5. `\l` to show databases
6. `\c db_name;` to connect to db_name made by the ORM or You
You can use Diesel at this point. But, you can also test it manually and use them to debug.
```console
CREATE TABLE demo_t(something int); // make table, CREATE TABLE demo_c(anychar char);
INSERT INTO demo_t (something) values (1); // Insert title and field to the table, edit table, or (anything) values ('$char')
DROP DATABASE demo_t // drop database
\dt // show table
\l // show database lists
SELECT * from demo_t;
\q
$DROP DATABASE IF EXISTS db_name;
```
## Setup Diesel with Cargo
```console
// I had a problem using Cargo with "linking with cc failed exit code 1"
// and could solve it with this comamnd.
$sudo apt install libpq-dev libmysqlclient-dev
$cargo install diesel_cli --no-default-features --features postgres or $cargo install diesel_cli
$cargo doc -p diesel --open
// 1. Set up Diesel in your project.
// 2. Create migration "create_posts".
// 3. Write SQL for migration.
// 4. Run it.
// 5. Redo if you want after you edit SQL you made before.
$diesel setup
$diesel migration create_post
// Move to migrations/ folder and use SQL similar to this.
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
title VARCHAR NOT NULL,
body TEXT NOT NULL
)
$diesel migration run
$diesel migraiton redo
# ALTER USER user_name WITH PASSWORD 'new_password';
# ALTER DATABASE name OWNER TO new_owner;
---
```
Refer to **$cargo run --bin [filename] [argument]** to use the binary file used for this example.
You can use **$history** for commands you used before.
It is not easy to find the blog posts with "id" when there are many of them. Use this instead.
```sql
SELECT title,id FROM posts WHERE posts.title LIKE 'Title%';
```
| {
"pile_set_name": "Github"
} |
; RUN: opt -S -place-safepoints < %s | FileCheck %s
declare void @callee()
define void @test() gc "statepoint-example" {
; CHECK-LABEL: test(
entry:
; CHECK: entry:
; CHECK: call void @do_safepoint()
br label %other
other:
; CHECK: other:
call void @callee() "gc-leaf-function"
; CHECK: call void @do_safepoint()
br label %other
}
declare void @do_safepoint()
define void @gc.safepoint_poll() {
call void @do_safepoint()
ret void
}
| {
"pile_set_name": "Github"
} |
//-----------------------------------------------------------------------------
// Configuration
//-----------------------------------------------------------------------------
namespace UnityEngine.Rendering.HighDefinition
{
[GenerateHLSL(PackingRules.Exact)]
public enum HDShadowFilteringQuality
{
Low = 0,
Medium = 1,
High = 2,
}
[GenerateHLSL(PackingRules.Exact)]
public enum ShaderOptions
{
CameraRelativeRendering = 1, // Rendering sets the origin of the world to the position of the primary (scene view) camera
PreExposition = 1,
PrecomputedAtmosphericAttenuation = 0, // Precomputes atmospheric attenuation for the directional light on the CPU, which makes it independent from the fragment's position, which is faster but wrong
#if ENABLE_RAYTRACING
Raytracing = 1,
#else
Raytracing = 0,
#endif
#if ENABLE_VR
XrMaxViews = 2, // Used for single-pass rendering (with fast path in vertex shader code when forced to 2)
#else
XrMaxViews = 1,
#endif
AreaLights = 0,
DeferredShadowFiltering = HDShadowFilteringQuality.Medium,
BarnDoor = 0
};
// Note: #define can't be use in include file in C# so we chose this way to configure both C# and hlsl
// Changing a value in this enum Config here require to regenerate the hlsl include and recompile C# and shaders
public class ShaderConfig
{
public static int s_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering;
public static int s_PreExposition = (int)ShaderOptions.PreExposition;
public static int s_XrMaxViews = (int)ShaderOptions.XrMaxViews;
public static int s_PrecomputedAtmosphericAttenuation = (int)ShaderOptions.PrecomputedAtmosphericAttenuation;
public static int s_AreaLights = (int)ShaderOptions.AreaLights;
public static int s_BarnDoor = (int)ShaderOptions.BarnDoor;
public static HDShadowFilteringQuality s_DeferredShadowFiltering = (HDShadowFilteringQuality)ShaderOptions.DeferredShadowFiltering;
}
}
| {
"pile_set_name": "Github"
} |
# Sample configuration file for a remote participant daemon
# If your using the AMQP listener/participant pair in ruote, you only
# need to specify the names of the queues to subscribe to.
defaults: &defaults
amqp:
queues:
- work1
#- work2
#- work3
development:
<<: *defaults
test:
<<: *defaults
staging:
<<: *defaults
production:
<<: *defaults
| {
"pile_set_name": "Github"
} |
RRCACHE_ARGS="-l unix:/var/run/rrdcached.sock -j /var/lib/rrdcached/journal/ -F -b /var/lib/rrdcached/db/ -B"
USER=""
GROUP=""
MODE=""
MAXWAIT=30
| {
"pile_set_name": "Github"
} |
/**
* @file
* IGMP protocol definitions
*/
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <[email protected]>
*
*/
#ifndef LWIP_HDR_PROT_IGMP_H
#define LWIP_HDR_PROT_IGMP_H
#include "lwip/arch.h"
#include "lwip/prot/ip4.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* IGMP constants
*/
#define IGMP_TTL 1
#define IGMP_MINLEN 8
#define ROUTER_ALERT 0x9404U
#define ROUTER_ALERTLEN 4
/*
* IGMP message types, including version number.
*/
#define IGMP_MEMB_QUERY 0x11 /* Membership query */
#define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */
#define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */
#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
/* Group membership states */
#define IGMP_GROUP_NON_MEMBER 0
#define IGMP_GROUP_DELAYING_MEMBER 1
#define IGMP_GROUP_IDLE_MEMBER 2
/**
* IGMP packet format.
*/
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
struct igmp_msg {
PACK_STRUCT_FLD_8(u8_t igmp_msgtype);
PACK_STRUCT_FLD_8(u8_t igmp_maxresp);
PACK_STRUCT_FIELD(u16_t igmp_checksum);
PACK_STRUCT_FLD_S(ip4_addr_p_t igmp_group_address);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#ifdef __cplusplus
}
#endif
#endif /* LWIP_HDR_PROT_IGMP_H */
| {
"pile_set_name": "Github"
} |
.
| {
"pile_set_name": "Github"
} |
# Aerospike Database Server
Welcome to the Aerospike Database Server source code tree!
Aerospike is a distributed, scalable NoSQL database. It is architected with three key objectives:
- To create a high-performance, scalable platform that would meet the needs of today's web-scale applications
- To provide the robustness and reliability (i.e., ACID) expected from traditional databases.
- To provide operational efficiency (minimal manual involvement)
For more information on Aerospike, please visit: [`http://aerospike.com`](http://aerospike.com)
## Telemetry Anonymized Data Collection
The Aerospike Community Edition collects anonymized server performance statistics.
Please see the
[Aerospike Telemetery web page](http://aerospike.com/aerospike-telemetry) for more
information. The full Telemetry data collection agent source code may be found in the
["telemetry" submodule](https://github.com/aerospike/aerospike-telemetry-agent/blob/master/README.md).
## Build Prerequisites
The Aerospike Database Server can be built and deployed on various
current 64-bit GNU/Linux platform versions, such as the Red Hat family (e.g.,
CentOS 6 or later), Debian 8 or later, and Ubuntu 16.04 or later.
### Dependencies
The majority of the Aerospike source code is written in the C
programming language, conforming to the ANSI C99 standard.
In particular, the following tools and libraries are needed:
#### C Compiler Toolchain
Building Aerospike requires the GCC 4.1 or later C compiler toolchain,
with the standard GNU/Linux development tools and libraries installed in
the build environment, including:
* `autoconf`
* `automake`
* `libtool`
* `make`
#### C++
The C++ compiler is required for the Aerospike geospatial indexing
feature and its dependency, Google's S2 Geometry Library (both written in C++.)
* The required CentOS 6/7/8 package to install is: `gcc-c++`.
* The required Debian 8/9/10 and Ubuntu 16/18/20 package to install is: `g++`.
#### OpenSSL
OpenSSL 0.9.8b or later is required for cryptographic hash functions
(RIPEMD-160 & SHA-1) and pseudo-random number generation.
* The CentOS 6/7/8 OpenSSL packages to install are: `openssl` and
`openssl-devel`, and also `openssl-static` on CentOS 6/7.
* The Debian 8/9/10 and Ubuntu 16/18/20 OpenSSL packages to install are:
`openssl` and `libssl-dev`.
#### Lua 5.1
The [Lua](http://www.lua.org) 5.1 language is required for User Defined
Function (UDF) support.
* By default, Aerospike builds with Lua 5.1 support provided by the
[LuaJIT](http://luajit.org) submodule.
* Alternatively, it is possible to build with standard Lua 5.1 provided
by the build environment. In that case:
* The CentOS 6/7/8 Lua package to install is: `lua`, and also
`lua-devel` and `lua-static` on CentOS 6/7.
* The Debian 8/9/10 and Ubuntu 16/18/20 Lua packages to install are:
`lua5.1` and `liblua5.1-dev`.
* Build by passing the `USE_LUAJIT=0` option to `make`.
#### zlib
Building on Ubuntu 18+ also requires installing `libz-dev`.
#### Python 3 or 2
Running the Telemetry Agent requires either Python 3+ or Python 2.6+,
at least one of which is generally available by default on most
platforms. On some distros, such as Ubuntu 16+, it may be necessary to
install the package `python`, while on other distros, such as CentOS 8,
the package name includes the major (and/or minor) version number, e.g.,
`python3` or `python2`.
### Submodules
The Aerospike Database Server build depends upon 8 submodules:
| Submodule | Description |
|---------- | ----------- |
| common | The Aerospike Common Library |
| jansson | C library for encoding, decoding and manipulating JSON data |
| jemalloc | The JEMalloc Memory Allocator |
| lua-core | The Aerospike Core Lua Source Files |
| luajit | The LuaJIT (Just-In-Time Compiler for Lua) |
| mod-lua | The Aerospike Lua Interface |
| s2-geometry-library | The S2 Spherical Geometry Library |
| telemetry | The Aerospike Telemetry Agent (Community Edition only) |
After the initial cloning of the `aerospike-server` repo., the
submodules must be fetched for the first time using the following
command:
$ git submodule update --init
*Note:* As this project uses submodules, the source archive downloadable
via GitHub's `Download ZIP` button will not build unless the correct
revision of each submodule is first manually installed in the appropriate
`modules` subdirectory.
## Building Aerospike
### Default Build
$ make -- Perform the default build (no packaging.)
*Note:* You can use the `-j` option with `make` to speed up the build
on multiple CPU cores. For example, to run four parallel jobs:
$ make -j4
### Build Options
$ make deb -- Build the Debian (Ubuntu) package.
$ make rpm -- Build the Red Hat Package Manager (RPM) package.
$ make tar -- Build the "Every Linux" compressed "tar" archive (".tgz") package.
$ make source -- Package the source code as a compressed "tar" archive.
$ make clean -- Delete any existing build products, excluding built packages.
$ make cleanpkg -- Delete built packages.
$ make cleanall -- Delete all existing build products, including built packages.
$ make cleangit -- Delete all files untracked by Git. (Use with caution!)
$ make strip -- Build a "strip(1)"ed version of the server executable.
### Overriding Default Build Options
$ make {<Target>}* {<VARIABLE>=<VALUE>}* -- Build <Target>(s) with optional variable overrides.
#### Example:
$ make USE_JEM=0 -- Default build *without* JEMalloc support.
## Configuring Aerospike
Sample Aerospike configuration files are provided in `as/etc`. The
developer configuration file, `aerospike_dev.conf`, contains basic
settings that should work out-of-the-box on most systems. The package
example configuration files, `aerospike.conf`, and the Solid State Drive
(SSD) version, `aerospike_ssd.conf`, are suitable for running Aerospike
as a system daemon.
These sample files may be modified for specific use cases (e.g., setting
network addresses, defining namespaces, and setting storage engine
properties) and tuned for for maximum performance on a particular
system. Also, system resource limits may need to be increased to allow,
e.g., a greater number of concurrent connections to the database. See
"man limits.conf" for how to change the system's limit on a process'
number of open file descriptors ("nofile".)
## Running Aerospike
There are several options for running the Aerospike database. Which
option to use depends upon whether the primary purpose is production
deployment or software development.
The preferred method for running Aerospike in a production environment
is to build and install the Aerospike package appropriate for the target
Linux distribution (i.e., an `".rpm"`, `".deb"`, or `".tgz"` file), and
then to control the state of the Aerospike daemon, either via the SysV
daemon init script commands, e.g., `service aerospike start`, or else
via `systemctl` on `systemd`-based systems, e.g., `systemctl start aerospike`.
A convenient way to run Aerospike in a development environment is to use
the following commands from within the top-level directory of the source
code tree (`aerospike-server`):
To create and initialize the `run` directory with the files needed for
running Aerospike, use:
$ make init
or, equivalently:
$ mkdir -p run/{log,work/{smd,{sys,usr}/udf/lua}}
$ cp -pr modules/lua-core/src/* run/work/sys/udf/lua
To launch the server with `as/etc/aerospike_dev.conf` as the config:
$ make start
or, equivalently:
$ nohup ./modules/telemetry/telemetry.py as/etc/telemetry_dev.conf > /dev/null 2>&1 &
$ target/Linux-x86_64/bin/asd --config-file as/etc/aerospike_dev.conf
To halt the server:
$ make stop
or, equivalently:
$ PID=`pgrep telemetry.py | grep -v grep`; if [ -n "$PID" ]; then kill $PID; fi
$ kill `cat run/asd.pid` ; rm run/asd.pid
Please refer to the full documentation on the Aerospike web site,
[`http://aerospike.com/docs/`](http://aerospike.com/docs/), for more
detailed information about configuring and running the Aerospike
Database Server, as well as about the Aerospike client API packages
for popular programming languages.
| {
"pile_set_name": "Github"
} |
============================
Frequently Asked Questions
============================
Questions
=========
Q: Message.reject doesn't work?
--------------------------------------
**Answer**: Earlier versions of RabbitMQ did not implement ``basic.reject``,
so make sure your version is recent enough to support it.
Q: Message.requeue doesn't work?
--------------------------------------
**Answer**: See _`Message.reject doesn't work?`
| {
"pile_set_name": "Github"
} |
// Package dtl implements the Azure ARM Dtl service API version 2018-09-15.
//
// The DevTest Labs Client.
package dtl
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// DefaultBaseURI is the default URI used for the service Dtl
DefaultBaseURI = "https://management.azure.com"
)
// BaseClient is the base client for Dtl.
type BaseClient struct {
autorest.Client
BaseURI string
SubscriptionID string
}
// New creates an instance of the BaseClient client.
func New(subscriptionID string) BaseClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with
// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
| {
"pile_set_name": "Github"
} |
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:3
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:4
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:5
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:6
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:7
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:8
gen.ads:6:19: medium: assertion might fail, cannot prove H < 0, in instantiation at inst.adb:9
inst.ads:11:14: warning: subprogram "P1" has no effect
| {
"pile_set_name": "Github"
} |
{
"_args": [
[
{
"raw": "qs@~6.3.0",
"scope": null,
"escapedName": "qs",
"name": "qs",
"rawSpec": "~6.3.0",
"spec": ">=6.3.0 <6.4.0",
"type": "range"
},
"D:\\Users\\aakash.h\\Desktop\\Ang5\\mat\\node_modules\\node-sass\\node_modules\\request"
]
],
"_from": "qs@>=6.3.0 <6.4.0",
"_id": "[email protected]",
"_inCache": true,
"_location": "/node-sass/qs",
"_nodeVersion": "7.7.1",
"_npmOperationalInternal": {
"host": "packages-18-east.internal.npmjs.com",
"tmp": "tmp/qs-6.3.2.tgz_1488790933355_0.4183437137398869"
},
"_npmUser": {
"name": "ljharb",
"email": "[email protected]"
},
"_npmVersion": "4.1.2",
"_phantomChildren": {},
"_requested": {
"raw": "qs@~6.3.0",
"scope": null,
"escapedName": "qs",
"name": "qs",
"rawSpec": "~6.3.0",
"spec": ">=6.3.0 <6.4.0",
"type": "range"
},
"_requiredBy": [
"/node-sass/request"
],
"_resolved": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz",
"_shasum": "e75bd5f6e268122a2a0e0bda630b2550c166502c",
"_shrinkwrap": null,
"_spec": "qs@~6.3.0",
"_where": "D:\\Users\\aakash.h\\Desktop\\Ang5\\mat\\node_modules\\node-sass\\node_modules\\request",
"bugs": {
"url": "https://github.com/ljharb/qs/issues"
},
"contributors": [
{
"name": "Jordan Harband",
"email": "[email protected]",
"url": "http://ljharb.codes"
}
],
"dependencies": {},
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"devDependencies": {
"@ljharb/eslint-config": "^11.0.0",
"browserify": "^14.1.0",
"covert": "^1.1.0",
"eslint": "^3.17.0",
"evalmd": "^0.0.17",
"iconv-lite": "^0.4.15",
"mkdirp": "^0.5.1",
"parallelshell": "^2.0.0",
"qs-iconv": "^1.0.4",
"safe-publish-latest": "^1.1.1",
"tape": "^4.6.3"
},
"directories": {},
"dist": {
"shasum": "e75bd5f6e268122a2a0e0bda630b2550c166502c",
"tarball": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz"
},
"engines": {
"node": ">=0.6"
},
"gitHead": "9ee56121311dac6b6014bfe56b3df0ebbf4ed048",
"homepage": "https://github.com/ljharb/qs",
"keywords": [
"querystring",
"qs"
],
"license": "BSD-3-Clause",
"main": "lib/index.js",
"maintainers": [
{
"name": "hueniverse",
"email": "[email protected]"
},
{
"name": "ljharb",
"email": "[email protected]"
},
{
"name": "nlf",
"email": "[email protected]"
}
],
"name": "qs",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/qs.git"
},
"scripts": {
"coverage": "covert test",
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
"lint": "eslint lib/*.js test/*.js",
"prepublish": "safe-publish-latest && npm run dist",
"pretest": "npm run --silent readme && npm run --silent lint",
"readme": "evalmd README.md",
"test": "npm run --silent coverage",
"tests-only": "node test"
},
"version": "6.3.2"
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) 1999 Patrik Stridvall
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#if defined(__WINE_PSHPACK_H15)
/* Depth > 15 */
# error "Alignment nesting > 15 is not supported"
#else
# if !defined(__WINE_PSHPACK_H)
# define __WINE_PSHPACK_H 2
/* Depth == 1 */
# elif !defined(__WINE_PSHPACK_H2)
# define __WINE_PSHPACK_H2 2
/* Depth == 2 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H3)
# define __WINE_PSHPACK_H3 2
/* Depth == 3 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H4)
# define __WINE_PSHPACK_H4 2
/* Depth == 4 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H5)
# define __WINE_PSHPACK_H5 2
/* Depth == 5 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H6)
# define __WINE_PSHPACK_H6 2
/* Depth == 6 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H7)
# define __WINE_PSHPACK_H7 2
/* Depth == 7 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H8)
# define __WINE_PSHPACK_H8 2
/* Depth == 8 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H9)
# define __WINE_PSHPACK_H9 2
/* Depth == 9 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H10)
# define __WINE_PSHPACK_H10 2
/* Depth == 10 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H11)
# define __WINE_PSHPACK_H11 2
/* Depth == 11 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H12)
# define __WINE_PSHPACK_H12 2
/* Depth == 12 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H13)
# define __WINE_PSHPACK_H13 2
/* Depth == 13 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H14)
# define __WINE_PSHPACK_H14 2
/* Depth == 14 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# elif !defined(__WINE_PSHPACK_H15)
# define __WINE_PSHPACK_H15 2
/* Depth == 15 */
# define __WINE_INTERNAL_POPPACK
# include <poppack.h>
# endif
# if defined(_MSC_VER) && (_MSC_VER >= 800)
# pragma warning(disable:4103)
# endif
# pragma pack(2)
#endif
| {
"pile_set_name": "Github"
} |
I have used:
- [ICO converter](http://www.icoconverter.com/) to generate the ico files from the png.
- [Gimp](http://www.gimp.org/) to convert from png to xpm.
| {
"pile_set_name": "Github"
} |
var mkdirp = require('../');
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
test('return value', function (t) {
t.plan(2);
var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var file = '/tmp/' + [x,y,z].join('/');
// should return the first dir created.
// By this point, it would be profoundly surprising if /tmp didn't
// already exist, since every other test makes things in there.
// Note that this will throw on failure, which will fail the test.
var made = mkdirp.sync(file);
t.equal(made, '/tmp/' + x);
// making the same file again should have no effect.
made = mkdirp.sync(file);
t.equal(made, null);
});
| {
"pile_set_name": "Github"
} |
mkdir log
start audioviewer
start flowdesigner LocalizeSeparAndSaveWavWin32.n
| {
"pile_set_name": "Github"
} |
fn foo() {
write!(&mut self.destination, "{}",
magic_number);
write![&mut self.destination, "{}",
magic_number];
write! {&mut self.destination, "{}",
magic_number}
}
| {
"pile_set_name": "Github"
} |
/**
* \file
*
* \brief Instance description for AC
*
* Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#ifndef _SAMD21_AC_INSTANCE_
#define _SAMD21_AC_INSTANCE_
/* ========== Register definition for AC peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_AC_CTRLA (0x42004400U) /**< \brief (AC) Control A */
#define REG_AC_CTRLB (0x42004401U) /**< \brief (AC) Control B */
#define REG_AC_EVCTRL (0x42004402U) /**< \brief (AC) Event Control */
#define REG_AC_INTENCLR (0x42004404U) /**< \brief (AC) Interrupt Enable Clear */
#define REG_AC_INTENSET (0x42004405U) /**< \brief (AC) Interrupt Enable Set */
#define REG_AC_INTFLAG (0x42004406U) /**< \brief (AC) Interrupt Flag Status and Clear */
#define REG_AC_STATUSA (0x42004408U) /**< \brief (AC) Status A */
#define REG_AC_STATUSB (0x42004409U) /**< \brief (AC) Status B */
#define REG_AC_STATUSC (0x4200440AU) /**< \brief (AC) Status C */
#define REG_AC_WINCTRL (0x4200440CU) /**< \brief (AC) Window Control */
#define REG_AC_COMPCTRL0 (0x42004410U) /**< \brief (AC) Comparator Control 0 */
#define REG_AC_COMPCTRL1 (0x42004414U) /**< \brief (AC) Comparator Control 1 */
#define REG_AC_SCALER0 (0x42004420U) /**< \brief (AC) Scaler 0 */
#define REG_AC_SCALER1 (0x42004421U) /**< \brief (AC) Scaler 1 */
#else
#define REG_AC_CTRLA (*(RwReg8 *)0x42004400U) /**< \brief (AC) Control A */
#define REG_AC_CTRLB (*(WoReg8 *)0x42004401U) /**< \brief (AC) Control B */
#define REG_AC_EVCTRL (*(RwReg16*)0x42004402U) /**< \brief (AC) Event Control */
#define REG_AC_INTENCLR (*(RwReg8 *)0x42004404U) /**< \brief (AC) Interrupt Enable Clear */
#define REG_AC_INTENSET (*(RwReg8 *)0x42004405U) /**< \brief (AC) Interrupt Enable Set */
#define REG_AC_INTFLAG (*(RwReg8 *)0x42004406U) /**< \brief (AC) Interrupt Flag Status and Clear */
#define REG_AC_STATUSA (*(RoReg8 *)0x42004408U) /**< \brief (AC) Status A */
#define REG_AC_STATUSB (*(RoReg8 *)0x42004409U) /**< \brief (AC) Status B */
#define REG_AC_STATUSC (*(RoReg8 *)0x4200440AU) /**< \brief (AC) Status C */
#define REG_AC_WINCTRL (*(RwReg8 *)0x4200440CU) /**< \brief (AC) Window Control */
#define REG_AC_COMPCTRL0 (*(RwReg *)0x42004410U) /**< \brief (AC) Comparator Control 0 */
#define REG_AC_COMPCTRL1 (*(RwReg *)0x42004414U) /**< \brief (AC) Comparator Control 1 */
#define REG_AC_SCALER0 (*(RwReg8 *)0x42004420U) /**< \brief (AC) Scaler 0 */
#define REG_AC_SCALER1 (*(RwReg8 *)0x42004421U) /**< \brief (AC) Scaler 1 */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
/* ========== Instance parameters for AC peripheral ========== */
#define AC_CMP_NUM 2 // Number of comparators
#define AC_GCLK_ID_ANA 32 // Index of Generic Clock for analog
#define AC_GCLK_ID_DIG 31 // Index of Generic Clock for digital
#define AC_NUM_CMP 2
#define AC_PAIRS 1 // Number of pairs of comparators
#endif /* _SAMD21_AC_INSTANCE_ */
| {
"pile_set_name": "Github"
} |
;Imports of matrix:
;Exports of matrix:
global dInvertPDMatrix3
global dSetValue
global dSetZero
SECTION .text
;dInvertPDMatrix3
dInvertPDMatrix3:
push ebp
mov ebp, esp
push edi
push esi
push ebx
sub esp, 0x64
mov edx, [ebp+0x8]
mov eax, [edx]
mov [ebp-0x58], eax
mov eax, [edx+0x4]
mov [ebp-0x54], eax
mov eax, [edx+0x8]
mov [ebp-0x50], eax
mov eax, [edx+0xc]
mov [ebp-0x4c], eax
mov eax, [edx+0x10]
mov [ebp-0x48], eax
mov eax, [edx+0x14]
mov [ebp-0x44], eax
mov eax, [edx+0x18]
mov [ebp-0x40], eax
mov eax, [edx+0x1c]
mov [ebp-0x3c], eax
mov eax, [edx+0x20]
mov [ebp-0x38], eax
mov eax, [edx+0x24]
mov [ebp-0x34], eax
mov eax, [edx+0x28]
mov [ebp-0x30], eax
mov eax, [edx+0x2c]
mov [ebp-0x2c], eax
lea eax, [ebp-0x58]
mov [ebp-0x64], eax
mov dword [ebp-0x68], 0x0
pxor xmm2, xmm2
movss xmm3, dword [_float_1_00000000]
dInvertPDMatrix3_50:
mov eax, [ebp-0x68]
test eax, eax
jg dInvertPDMatrix3_10
mov esi, [ebp-0x64]
dInvertPDMatrix3_210:
movss xmm1, dword [esi]
mov edi, [ebp-0x68]
test edi, edi
jz dInvertPDMatrix3_20
mov eax, [ebp-0x64]
xor edx, edx
dInvertPDMatrix3_30:
movss xmm0, dword [eax]
mulss xmm0, xmm0
subss xmm1, xmm0
add eax, 0x4
add edx, 0x1
cmp edx, [ebp-0x68]
jnz dInvertPDMatrix3_30
dInvertPDMatrix3_20:
ucomiss xmm2, xmm1
jae dInvertPDMatrix3_40
sqrtss xmm0, xmm1
movss [esi], xmm0
movaps xmm1, xmm3
divss xmm1, xmm0
mov eax, [ebp-0x68]
movss [ebp+eax*4-0x28], xmm1
add dword [ebp-0x64], 0x10
add eax, 0x1
mov [ebp-0x68], eax
cmp eax, 0x3
jnz dInvertPDMatrix3_50
mov eax, [ebp+0xc]
mov edx, 0xc
dInvertPDMatrix3_60:
mov dword [eax], 0x0
add eax, 0x4
sub edx, 0x1
jnz dInvertPDMatrix3_60
mov eax, [ebp+0xc]
mov [ebp-0x6c], eax
mov dword [ebp-0x70], 0x0
dInvertPDMatrix3_150:
mov eax, 0x1
dInvertPDMatrix3_70:
mov dword [ebp+eax*4-0x20], 0x0
add eax, 0x1
cmp eax, 0x4
jnz dInvertPDMatrix3_70
mov eax, [ebp-0x70]
mov dword [ebp+eax*4-0x1c], 0x3f800000
xor ebx, ebx
xor ecx, ecx
dInvertPDMatrix3_90:
movaps xmm1, xmm2
dInvertPDMatrix3_110:
lea eax, [ecx*4]
movss xmm0, dword [ebp+eax-0x1c]
subss xmm0, xmm1
lea edx, [ecx+ebx]
divss xmm0, dword [ebp+edx*4-0x58]
movss [ebp+eax-0x28], xmm0
add ecx, 0x1
add ebx, 0x4
cmp ecx, 0x3
jz dInvertPDMatrix3_80
test ecx, ecx
jle dInvertPDMatrix3_90
mov eax, ecx
shl eax, 0x4
xor edx, edx
movaps xmm1, xmm2
dInvertPDMatrix3_100:
movss xmm0, dword [ebp+eax-0x58]
mulss xmm0, [ebp+edx*4-0x28]
addss xmm1, xmm0
add edx, 0x1
add eax, 0x4
cmp ecx, edx
jnz dInvertPDMatrix3_100
jmp dInvertPDMatrix3_110
dInvertPDMatrix3_80:
mov ebx, 0x3
mov edi, 0x38
mov esi, 0xc
dInvertPDMatrix3_130:
mov ecx, ebx
cmp ebx, 0x2
jle dInvertPDMatrix3_120
movaps xmm1, xmm2
dInvertPDMatrix3_170:
movss xmm0, dword [esi+ebp-0x2c]
subss xmm0, xmm1
divss xmm0, dword [edi+ebp-0x68]
movss [esi+ebp-0x20], xmm0
sub esi, 0x4
sub edi, 0x14
sub ebx, 0x1
jnz dInvertPDMatrix3_130
mov edx, [ebp-0x6c]
mov ecx, 0x1
dInvertPDMatrix3_140:
mov eax, [ebp+ecx*4-0x20]
mov [edx], eax
add ecx, 0x1
add edx, 0x10
cmp ecx, 0x4
jnz dInvertPDMatrix3_140
add dword [ebp-0x70], 0x1
add dword [ebp-0x6c], 0x4
cmp dword [ebp-0x70], 0x3
jnz dInvertPDMatrix3_150
mov eax, 0x1
add esp, 0x64
pop ebx
pop esi
pop edi
pop ebp
ret
dInvertPDMatrix3_120:
mov edx, edi
lea eax, [ebx*4]
movaps xmm1, xmm2
dInvertPDMatrix3_160:
movss xmm0, dword [ebp+edx-0x58]
mulss xmm0, [ebp+eax-0x1c]
addss xmm1, xmm0
add ecx, 0x1
add edx, 0x10
add eax, 0x4
cmp ecx, 0x3
jnz dInvertPDMatrix3_160
jmp dInvertPDMatrix3_170
dInvertPDMatrix3_10:
mov esi, [ebp-0x64]
lea edi, [ebp-0x58]
xor ebx, ebx
dInvertPDMatrix3_200:
movss xmm1, dword [esi]
test ebx, ebx
jz dInvertPDMatrix3_180
mov edx, [ebp-0x64]
mov eax, edi
xor ecx, ecx
dInvertPDMatrix3_190:
movss xmm0, dword [edx]
mulss xmm0, [eax]
subss xmm1, xmm0
add edx, 0x4
add eax, 0x4
add ecx, 0x1
cmp ecx, ebx
jnz dInvertPDMatrix3_190
dInvertPDMatrix3_180:
mulss xmm1, [ebp+ebx*4-0x28]
movss [esi], xmm1
add edi, 0x10
add esi, 0x4
add ebx, 0x1
cmp ebx, [ebp-0x68]
jnz dInvertPDMatrix3_200
jmp dInvertPDMatrix3_210
dInvertPDMatrix3_40:
xor eax, eax
add esp, 0x64
pop ebx
pop esi
pop edi
pop ebp
ret
add [eax], al
;dSetValue
dSetValue:
push ebp
mov ebp, esp
push ebx
mov eax, [ebp+0x8]
mov ecx, [ebp+0xc]
mov ebx, [ebp+0x10]
test ecx, ecx
jle dSetValue_10
xor edx, edx
dSetValue_20:
mov [eax], ebx
add eax, 0x4
add edx, 0x1
cmp ecx, edx
jnz dSetValue_20
dSetValue_10:
pop ebx
pop ebp
ret
;dSetZero
dSetZero:
push ebp
mov ebp, esp
mov eax, [ebp+0x8]
mov ecx, [ebp+0xc]
test ecx, ecx
jle dSetZero_10
xor edx, edx
dSetZero_20:
mov dword [eax], 0x0
add eax, 0x4
add edx, 0x1
cmp ecx, edx
jnz dSetZero_20
dSetZero_10:
pop ebp
ret
nop
;Initialized global or static variables of matrix:
SECTION .data
;Initialized constant data of matrix:
SECTION .rdata
;Zero initialized global or static variables of matrix:
SECTION .bss
;All cstrings:
SECTION .rdata
;All constant floats and doubles:
SECTION .rdata
_float_1_00000000: dd 0x3f800000 ; 1
| {
"pile_set_name": "Github"
} |
/* eslint-disable */
var array = require('../wxs/array.wxs');
function isActive (activeList, itemId) {
if (array.isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
return activeList === itemId;
}
module.exports.isActive = isActive;
| {
"pile_set_name": "Github"
} |
{
"name": "nolimits4web/swiper",
"license": [
"MIT"
],
"extra": {},
"authors": [
{
"homepage": "https://idangero.us",
"role": "Developer",
"name": "Vladimir Kharalmpidi",
"email": "[email protected]"
}
],
"keywords": [
"swiper",
"swipe",
"slider",
"touch",
"ios",
"mobile",
"cordova",
"phonegap",
"app",
"framework",
"framework7",
"carousel",
"gallery",
"plugin"
],
"support": {
"issues": "https://github.com/nolimits4web/swiper/issues",
"source": "https://github.com/nolimits4web/swiper.git",
"docs": "http://idangero.us/swiper/api/"
},
"homepage": "http://www.idangero.us/swiper/",
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions"
}
| {
"pile_set_name": "Github"
} |
<?php
declare(strict_types=1);
/**
* @copyright 2017 Christoph Wurst <[email protected]>
*
* @author 2017 Christoph Wurst <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Mail\Service\Avatar;
use JsonSerializable;
class Avatar implements JsonSerializable {
/** @var string */
private $url;
/** @var string|null */
private $mime;
/** @var bool */
private $isExternal;
/**
* @param string $url
* @param string|null $mime
* @param bool $isExternal
*/
public function __construct(string $url, string $mime = null, bool $isExternal = true) {
$this->url = $url;
$this->mime = $mime;
$this->isExternal = $isExternal;
}
/**
* @return string
*/
public function getUrl(): string {
return $this->url;
}
/**
* Get the MIME type of this avatar
*
* @return string|null
*/
public function getMime() {
return $this->mime;
}
/**
* @return bool
*/
public function isExternal(): bool {
return $this->isExternal;
}
/**
* @return array
*/
public function jsonSerialize(): array {
return [
'isExternal' => $this->isExternal,
'mime' => $this->mime,
'url' => $this->url,
];
}
}
| {
"pile_set_name": "Github"
} |
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Analog Devices ADAU1373 Audio Codec drive
*
* Copyright 2011 Analog Devices Inc.
* Author: Lars-Peter Clausen <[email protected]>
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/gcd.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/tlv.h>
#include <sound/soc.h>
#include <sound/adau1373.h>
#include "adau1373.h"
#include "adau-utils.h"
struct adau1373_dai {
unsigned int clk_src;
unsigned int sysclk;
bool enable_src;
bool master;
};
struct adau1373 {
struct regmap *regmap;
struct adau1373_dai dais[3];
};
#define ADAU1373_INPUT_MODE 0x00
#define ADAU1373_AINL_CTRL(x) (0x01 + (x) * 2)
#define ADAU1373_AINR_CTRL(x) (0x02 + (x) * 2)
#define ADAU1373_LLINE_OUT(x) (0x9 + (x) * 2)
#define ADAU1373_RLINE_OUT(x) (0xa + (x) * 2)
#define ADAU1373_LSPK_OUT 0x0d
#define ADAU1373_RSPK_OUT 0x0e
#define ADAU1373_LHP_OUT 0x0f
#define ADAU1373_RHP_OUT 0x10
#define ADAU1373_ADC_GAIN 0x11
#define ADAU1373_LADC_MIXER 0x12
#define ADAU1373_RADC_MIXER 0x13
#define ADAU1373_LLINE1_MIX 0x14
#define ADAU1373_RLINE1_MIX 0x15
#define ADAU1373_LLINE2_MIX 0x16
#define ADAU1373_RLINE2_MIX 0x17
#define ADAU1373_LSPK_MIX 0x18
#define ADAU1373_RSPK_MIX 0x19
#define ADAU1373_LHP_MIX 0x1a
#define ADAU1373_RHP_MIX 0x1b
#define ADAU1373_EP_MIX 0x1c
#define ADAU1373_HP_CTRL 0x1d
#define ADAU1373_HP_CTRL2 0x1e
#define ADAU1373_LS_CTRL 0x1f
#define ADAU1373_EP_CTRL 0x21
#define ADAU1373_MICBIAS_CTRL1 0x22
#define ADAU1373_MICBIAS_CTRL2 0x23
#define ADAU1373_OUTPUT_CTRL 0x24
#define ADAU1373_PWDN_CTRL1 0x25
#define ADAU1373_PWDN_CTRL2 0x26
#define ADAU1373_PWDN_CTRL3 0x27
#define ADAU1373_DPLL_CTRL(x) (0x28 + (x) * 7)
#define ADAU1373_PLL_CTRL1(x) (0x29 + (x) * 7)
#define ADAU1373_PLL_CTRL2(x) (0x2a + (x) * 7)
#define ADAU1373_PLL_CTRL3(x) (0x2b + (x) * 7)
#define ADAU1373_PLL_CTRL4(x) (0x2c + (x) * 7)
#define ADAU1373_PLL_CTRL5(x) (0x2d + (x) * 7)
#define ADAU1373_PLL_CTRL6(x) (0x2e + (x) * 7)
#define ADAU1373_HEADDECT 0x36
#define ADAU1373_ADC_DAC_STATUS 0x37
#define ADAU1373_ADC_CTRL 0x3c
#define ADAU1373_DAI(x) (0x44 + (x))
#define ADAU1373_CLK_SRC_DIV(x) (0x40 + (x) * 2)
#define ADAU1373_BCLKDIV(x) (0x47 + (x))
#define ADAU1373_SRC_RATIOA(x) (0x4a + (x) * 2)
#define ADAU1373_SRC_RATIOB(x) (0x4b + (x) * 2)
#define ADAU1373_DEEMP_CTRL 0x50
#define ADAU1373_SRC_DAI_CTRL(x) (0x51 + (x))
#define ADAU1373_DIN_MIX_CTRL(x) (0x56 + (x))
#define ADAU1373_DOUT_MIX_CTRL(x) (0x5b + (x))
#define ADAU1373_DAI_PBL_VOL(x) (0x62 + (x) * 2)
#define ADAU1373_DAI_PBR_VOL(x) (0x63 + (x) * 2)
#define ADAU1373_DAI_RECL_VOL(x) (0x68 + (x) * 2)
#define ADAU1373_DAI_RECR_VOL(x) (0x69 + (x) * 2)
#define ADAU1373_DAC1_PBL_VOL 0x6e
#define ADAU1373_DAC1_PBR_VOL 0x6f
#define ADAU1373_DAC2_PBL_VOL 0x70
#define ADAU1373_DAC2_PBR_VOL 0x71
#define ADAU1373_ADC_RECL_VOL 0x72
#define ADAU1373_ADC_RECR_VOL 0x73
#define ADAU1373_DMIC_RECL_VOL 0x74
#define ADAU1373_DMIC_RECR_VOL 0x75
#define ADAU1373_VOL_GAIN1 0x76
#define ADAU1373_VOL_GAIN2 0x77
#define ADAU1373_VOL_GAIN3 0x78
#define ADAU1373_HPF_CTRL 0x7d
#define ADAU1373_BASS1 0x7e
#define ADAU1373_BASS2 0x7f
#define ADAU1373_DRC(x) (0x80 + (x) * 0x10)
#define ADAU1373_3D_CTRL1 0xc0
#define ADAU1373_3D_CTRL2 0xc1
#define ADAU1373_FDSP_SEL1 0xdc
#define ADAU1373_FDSP_SEL2 0xdd
#define ADAU1373_FDSP_SEL3 0xde
#define ADAU1373_FDSP_SEL4 0xdf
#define ADAU1373_DIGMICCTRL 0xe2
#define ADAU1373_DIGEN 0xeb
#define ADAU1373_SOFT_RESET 0xff
#define ADAU1373_PLL_CTRL6_DPLL_BYPASS BIT(1)
#define ADAU1373_PLL_CTRL6_PLL_EN BIT(0)
#define ADAU1373_DAI_INVERT_BCLK BIT(7)
#define ADAU1373_DAI_MASTER BIT(6)
#define ADAU1373_DAI_INVERT_LRCLK BIT(4)
#define ADAU1373_DAI_WLEN_16 0x0
#define ADAU1373_DAI_WLEN_20 0x4
#define ADAU1373_DAI_WLEN_24 0x8
#define ADAU1373_DAI_WLEN_32 0xc
#define ADAU1373_DAI_WLEN_MASK 0xc
#define ADAU1373_DAI_FORMAT_RIGHT_J 0x0
#define ADAU1373_DAI_FORMAT_LEFT_J 0x1
#define ADAU1373_DAI_FORMAT_I2S 0x2
#define ADAU1373_DAI_FORMAT_DSP 0x3
#define ADAU1373_BCLKDIV_SOURCE BIT(5)
#define ADAU1373_BCLKDIV_SR_MASK (0x07 << 2)
#define ADAU1373_BCLKDIV_BCLK_MASK 0x03
#define ADAU1373_BCLKDIV_32 0x03
#define ADAU1373_BCLKDIV_64 0x02
#define ADAU1373_BCLKDIV_128 0x01
#define ADAU1373_BCLKDIV_256 0x00
#define ADAU1373_ADC_CTRL_PEAK_DETECT BIT(0)
#define ADAU1373_ADC_CTRL_RESET BIT(1)
#define ADAU1373_ADC_CTRL_RESET_FORCE BIT(2)
#define ADAU1373_OUTPUT_CTRL_LDIFF BIT(3)
#define ADAU1373_OUTPUT_CTRL_LNFBEN BIT(2)
#define ADAU1373_PWDN_CTRL3_PWR_EN BIT(0)
#define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4
#define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2
static const struct reg_default adau1373_reg_defaults[] = {
{ ADAU1373_INPUT_MODE, 0x00 },
{ ADAU1373_AINL_CTRL(0), 0x00 },
{ ADAU1373_AINR_CTRL(0), 0x00 },
{ ADAU1373_AINL_CTRL(1), 0x00 },
{ ADAU1373_AINR_CTRL(1), 0x00 },
{ ADAU1373_AINL_CTRL(2), 0x00 },
{ ADAU1373_AINR_CTRL(2), 0x00 },
{ ADAU1373_AINL_CTRL(3), 0x00 },
{ ADAU1373_AINR_CTRL(3), 0x00 },
{ ADAU1373_LLINE_OUT(0), 0x00 },
{ ADAU1373_RLINE_OUT(0), 0x00 },
{ ADAU1373_LLINE_OUT(1), 0x00 },
{ ADAU1373_RLINE_OUT(1), 0x00 },
{ ADAU1373_LSPK_OUT, 0x00 },
{ ADAU1373_RSPK_OUT, 0x00 },
{ ADAU1373_LHP_OUT, 0x00 },
{ ADAU1373_RHP_OUT, 0x00 },
{ ADAU1373_ADC_GAIN, 0x00 },
{ ADAU1373_LADC_MIXER, 0x00 },
{ ADAU1373_RADC_MIXER, 0x00 },
{ ADAU1373_LLINE1_MIX, 0x00 },
{ ADAU1373_RLINE1_MIX, 0x00 },
{ ADAU1373_LLINE2_MIX, 0x00 },
{ ADAU1373_RLINE2_MIX, 0x00 },
{ ADAU1373_LSPK_MIX, 0x00 },
{ ADAU1373_RSPK_MIX, 0x00 },
{ ADAU1373_LHP_MIX, 0x00 },
{ ADAU1373_RHP_MIX, 0x00 },
{ ADAU1373_EP_MIX, 0x00 },
{ ADAU1373_HP_CTRL, 0x00 },
{ ADAU1373_HP_CTRL2, 0x00 },
{ ADAU1373_LS_CTRL, 0x00 },
{ ADAU1373_EP_CTRL, 0x00 },
{ ADAU1373_MICBIAS_CTRL1, 0x00 },
{ ADAU1373_MICBIAS_CTRL2, 0x00 },
{ ADAU1373_OUTPUT_CTRL, 0x00 },
{ ADAU1373_PWDN_CTRL1, 0x00 },
{ ADAU1373_PWDN_CTRL2, 0x00 },
{ ADAU1373_PWDN_CTRL3, 0x00 },
{ ADAU1373_DPLL_CTRL(0), 0x00 },
{ ADAU1373_PLL_CTRL1(0), 0x00 },
{ ADAU1373_PLL_CTRL2(0), 0x00 },
{ ADAU1373_PLL_CTRL3(0), 0x00 },
{ ADAU1373_PLL_CTRL4(0), 0x00 },
{ ADAU1373_PLL_CTRL5(0), 0x00 },
{ ADAU1373_PLL_CTRL6(0), 0x02 },
{ ADAU1373_DPLL_CTRL(1), 0x00 },
{ ADAU1373_PLL_CTRL1(1), 0x00 },
{ ADAU1373_PLL_CTRL2(1), 0x00 },
{ ADAU1373_PLL_CTRL3(1), 0x00 },
{ ADAU1373_PLL_CTRL4(1), 0x00 },
{ ADAU1373_PLL_CTRL5(1), 0x00 },
{ ADAU1373_PLL_CTRL6(1), 0x02 },
{ ADAU1373_HEADDECT, 0x00 },
{ ADAU1373_ADC_CTRL, 0x00 },
{ ADAU1373_CLK_SRC_DIV(0), 0x00 },
{ ADAU1373_CLK_SRC_DIV(1), 0x00 },
{ ADAU1373_DAI(0), 0x0a },
{ ADAU1373_DAI(1), 0x0a },
{ ADAU1373_DAI(2), 0x0a },
{ ADAU1373_BCLKDIV(0), 0x00 },
{ ADAU1373_BCLKDIV(1), 0x00 },
{ ADAU1373_BCLKDIV(2), 0x00 },
{ ADAU1373_SRC_RATIOA(0), 0x00 },
{ ADAU1373_SRC_RATIOB(0), 0x00 },
{ ADAU1373_SRC_RATIOA(1), 0x00 },
{ ADAU1373_SRC_RATIOB(1), 0x00 },
{ ADAU1373_SRC_RATIOA(2), 0x00 },
{ ADAU1373_SRC_RATIOB(2), 0x00 },
{ ADAU1373_DEEMP_CTRL, 0x00 },
{ ADAU1373_SRC_DAI_CTRL(0), 0x08 },
{ ADAU1373_SRC_DAI_CTRL(1), 0x08 },
{ ADAU1373_SRC_DAI_CTRL(2), 0x08 },
{ ADAU1373_DIN_MIX_CTRL(0), 0x00 },
{ ADAU1373_DIN_MIX_CTRL(1), 0x00 },
{ ADAU1373_DIN_MIX_CTRL(2), 0x00 },
{ ADAU1373_DIN_MIX_CTRL(3), 0x00 },
{ ADAU1373_DIN_MIX_CTRL(4), 0x00 },
{ ADAU1373_DOUT_MIX_CTRL(0), 0x00 },
{ ADAU1373_DOUT_MIX_CTRL(1), 0x00 },
{ ADAU1373_DOUT_MIX_CTRL(2), 0x00 },
{ ADAU1373_DOUT_MIX_CTRL(3), 0x00 },
{ ADAU1373_DOUT_MIX_CTRL(4), 0x00 },
{ ADAU1373_DAI_PBL_VOL(0), 0x00 },
{ ADAU1373_DAI_PBR_VOL(0), 0x00 },
{ ADAU1373_DAI_PBL_VOL(1), 0x00 },
{ ADAU1373_DAI_PBR_VOL(1), 0x00 },
{ ADAU1373_DAI_PBL_VOL(2), 0x00 },
{ ADAU1373_DAI_PBR_VOL(2), 0x00 },
{ ADAU1373_DAI_RECL_VOL(0), 0x00 },
{ ADAU1373_DAI_RECR_VOL(0), 0x00 },
{ ADAU1373_DAI_RECL_VOL(1), 0x00 },
{ ADAU1373_DAI_RECR_VOL(1), 0x00 },
{ ADAU1373_DAI_RECL_VOL(2), 0x00 },
{ ADAU1373_DAI_RECR_VOL(2), 0x00 },
{ ADAU1373_DAC1_PBL_VOL, 0x00 },
{ ADAU1373_DAC1_PBR_VOL, 0x00 },
{ ADAU1373_DAC2_PBL_VOL, 0x00 },
{ ADAU1373_DAC2_PBR_VOL, 0x00 },
{ ADAU1373_ADC_RECL_VOL, 0x00 },
{ ADAU1373_ADC_RECR_VOL, 0x00 },
{ ADAU1373_DMIC_RECL_VOL, 0x00 },
{ ADAU1373_DMIC_RECR_VOL, 0x00 },
{ ADAU1373_VOL_GAIN1, 0x00 },
{ ADAU1373_VOL_GAIN2, 0x00 },
{ ADAU1373_VOL_GAIN3, 0x00 },
{ ADAU1373_HPF_CTRL, 0x00 },
{ ADAU1373_BASS1, 0x00 },
{ ADAU1373_BASS2, 0x00 },
{ ADAU1373_DRC(0) + 0x0, 0x78 },
{ ADAU1373_DRC(0) + 0x1, 0x18 },
{ ADAU1373_DRC(0) + 0x2, 0x00 },
{ ADAU1373_DRC(0) + 0x3, 0x00 },
{ ADAU1373_DRC(0) + 0x4, 0x00 },
{ ADAU1373_DRC(0) + 0x5, 0xc0 },
{ ADAU1373_DRC(0) + 0x6, 0x00 },
{ ADAU1373_DRC(0) + 0x7, 0x00 },
{ ADAU1373_DRC(0) + 0x8, 0x00 },
{ ADAU1373_DRC(0) + 0x9, 0xc0 },
{ ADAU1373_DRC(0) + 0xa, 0x88 },
{ ADAU1373_DRC(0) + 0xb, 0x7a },
{ ADAU1373_DRC(0) + 0xc, 0xdf },
{ ADAU1373_DRC(0) + 0xd, 0x20 },
{ ADAU1373_DRC(0) + 0xe, 0x00 },
{ ADAU1373_DRC(0) + 0xf, 0x00 },
{ ADAU1373_DRC(1) + 0x0, 0x78 },
{ ADAU1373_DRC(1) + 0x1, 0x18 },
{ ADAU1373_DRC(1) + 0x2, 0x00 },
{ ADAU1373_DRC(1) + 0x3, 0x00 },
{ ADAU1373_DRC(1) + 0x4, 0x00 },
{ ADAU1373_DRC(1) + 0x5, 0xc0 },
{ ADAU1373_DRC(1) + 0x6, 0x00 },
{ ADAU1373_DRC(1) + 0x7, 0x00 },
{ ADAU1373_DRC(1) + 0x8, 0x00 },
{ ADAU1373_DRC(1) + 0x9, 0xc0 },
{ ADAU1373_DRC(1) + 0xa, 0x88 },
{ ADAU1373_DRC(1) + 0xb, 0x7a },
{ ADAU1373_DRC(1) + 0xc, 0xdf },
{ ADAU1373_DRC(1) + 0xd, 0x20 },
{ ADAU1373_DRC(1) + 0xe, 0x00 },
{ ADAU1373_DRC(1) + 0xf, 0x00 },
{ ADAU1373_DRC(2) + 0x0, 0x78 },
{ ADAU1373_DRC(2) + 0x1, 0x18 },
{ ADAU1373_DRC(2) + 0x2, 0x00 },
{ ADAU1373_DRC(2) + 0x3, 0x00 },
{ ADAU1373_DRC(2) + 0x4, 0x00 },
{ ADAU1373_DRC(2) + 0x5, 0xc0 },
{ ADAU1373_DRC(2) + 0x6, 0x00 },
{ ADAU1373_DRC(2) + 0x7, 0x00 },
{ ADAU1373_DRC(2) + 0x8, 0x00 },
{ ADAU1373_DRC(2) + 0x9, 0xc0 },
{ ADAU1373_DRC(2) + 0xa, 0x88 },
{ ADAU1373_DRC(2) + 0xb, 0x7a },
{ ADAU1373_DRC(2) + 0xc, 0xdf },
{ ADAU1373_DRC(2) + 0xd, 0x20 },
{ ADAU1373_DRC(2) + 0xe, 0x00 },
{ ADAU1373_DRC(2) + 0xf, 0x00 },
{ ADAU1373_3D_CTRL1, 0x00 },
{ ADAU1373_3D_CTRL2, 0x00 },
{ ADAU1373_FDSP_SEL1, 0x00 },
{ ADAU1373_FDSP_SEL2, 0x00 },
{ ADAU1373_FDSP_SEL2, 0x00 },
{ ADAU1373_FDSP_SEL4, 0x00 },
{ ADAU1373_DIGMICCTRL, 0x00 },
{ ADAU1373_DIGEN, 0x00 },
};
static const DECLARE_TLV_DB_RANGE(adau1373_out_tlv,
0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
);
static const DECLARE_TLV_DB_MINMAX(adau1373_digital_tlv, -9563, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_in_pga_tlv, -1300, 100, 1);
static const DECLARE_TLV_DB_SCALE(adau1373_ep_tlv, -600, 600, 1);
static const DECLARE_TLV_DB_SCALE(adau1373_input_boost_tlv, 0, 2000, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_gain_boost_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_speaker_boost_tlv, 1200, 600, 0);
static const char *adau1373_fdsp_sel_text[] = {
"None",
"Channel 1",
"Channel 2",
"Channel 3",
"Channel 4",
"Channel 5",
};
static SOC_ENUM_SINGLE_DECL(adau1373_drc1_channel_enum,
ADAU1373_FDSP_SEL1, 4, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_drc2_channel_enum,
ADAU1373_FDSP_SEL1, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_drc3_channel_enum,
ADAU1373_FDSP_SEL2, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_hpf_channel_enum,
ADAU1373_FDSP_SEL3, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_channel_enum,
ADAU1373_FDSP_SEL4, 4, adau1373_fdsp_sel_text);
static const char *adau1373_hpf_cutoff_text[] = {
"3.7Hz", "50Hz", "100Hz", "150Hz", "200Hz", "250Hz", "300Hz", "350Hz",
"400Hz", "450Hz", "500Hz", "550Hz", "600Hz", "650Hz", "700Hz", "750Hz",
"800Hz",
};
static SOC_ENUM_SINGLE_DECL(adau1373_hpf_cutoff_enum,
ADAU1373_HPF_CTRL, 3, adau1373_hpf_cutoff_text);
static const char *adau1373_bass_lpf_cutoff_text[] = {
"801Hz", "1001Hz",
};
static const char *adau1373_bass_clip_level_text[] = {
"0.125", "0.250", "0.370", "0.500", "0.625", "0.750", "0.875",
};
static const unsigned int adau1373_bass_clip_level_values[] = {
1, 2, 3, 4, 5, 6, 7,
};
static const char *adau1373_bass_hpf_cutoff_text[] = {
"158Hz", "232Hz", "347Hz", "520Hz",
};
static const DECLARE_TLV_DB_RANGE(adau1373_bass_tlv,
0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1),
3, 4, TLV_DB_SCALE_ITEM(950, 250, 0),
5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0)
);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum,
ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text);
static SOC_VALUE_ENUM_SINGLE_DECL(adau1373_bass_clip_level_enum,
ADAU1373_BASS1, 2, 7, adau1373_bass_clip_level_text,
adau1373_bass_clip_level_values);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_hpf_cutoff_enum,
ADAU1373_BASS1, 0, adau1373_bass_hpf_cutoff_text);
static const char *adau1373_3d_level_text[] = {
"0%", "6.67%", "13.33%", "20%", "26.67%", "33.33%",
"40%", "46.67%", "53.33%", "60%", "66.67%", "73.33%",
"80%", "86.67", "99.33%", "100%"
};
static const char *adau1373_3d_cutoff_text[] = {
"No 3D", "0.03125 fs", "0.04583 fs", "0.075 fs", "0.11458 fs",
"0.16875 fs", "0.27083 fs"
};
static SOC_ENUM_SINGLE_DECL(adau1373_3d_level_enum,
ADAU1373_3D_CTRL1, 4, adau1373_3d_level_text);
static SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum,
ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text);
static const DECLARE_TLV_DB_RANGE(adau1373_3d_tlv,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_LINEAR_ITEM(-1800, -120)
);
static const char *adau1373_lr_mux_text[] = {
"Mute",
"Right Channel (L+R)",
"Left Channel (L+R)",
"Stereo",
};
static SOC_ENUM_SINGLE_DECL(adau1373_lineout1_lr_mux_enum,
ADAU1373_OUTPUT_CTRL, 4, adau1373_lr_mux_text);
static SOC_ENUM_SINGLE_DECL(adau1373_lineout2_lr_mux_enum,
ADAU1373_OUTPUT_CTRL, 6, adau1373_lr_mux_text);
static SOC_ENUM_SINGLE_DECL(adau1373_speaker_lr_mux_enum,
ADAU1373_LS_CTRL, 4, adau1373_lr_mux_text);
static const struct snd_kcontrol_new adau1373_controls[] = {
SOC_DOUBLE_R_TLV("AIF1 Capture Volume", ADAU1373_DAI_RECL_VOL(0),
ADAU1373_DAI_RECR_VOL(0), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("AIF2 Capture Volume", ADAU1373_DAI_RECL_VOL(1),
ADAU1373_DAI_RECR_VOL(1), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("AIF3 Capture Volume", ADAU1373_DAI_RECL_VOL(2),
ADAU1373_DAI_RECR_VOL(2), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("ADC Capture Volume", ADAU1373_ADC_RECL_VOL,
ADAU1373_ADC_RECR_VOL, 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("DMIC Capture Volume", ADAU1373_DMIC_RECL_VOL,
ADAU1373_DMIC_RECR_VOL, 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("AIF1 Playback Volume", ADAU1373_DAI_PBL_VOL(0),
ADAU1373_DAI_PBR_VOL(0), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("AIF2 Playback Volume", ADAU1373_DAI_PBL_VOL(1),
ADAU1373_DAI_PBR_VOL(1), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("AIF3 Playback Volume", ADAU1373_DAI_PBL_VOL(2),
ADAU1373_DAI_PBR_VOL(2), 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("DAC1 Playback Volume", ADAU1373_DAC1_PBL_VOL,
ADAU1373_DAC1_PBR_VOL, 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("DAC2 Playback Volume", ADAU1373_DAC2_PBL_VOL,
ADAU1373_DAC2_PBR_VOL, 0, 0xff, 1, adau1373_digital_tlv),
SOC_DOUBLE_R_TLV("Lineout1 Playback Volume", ADAU1373_LLINE_OUT(0),
ADAU1373_RLINE_OUT(0), 0, 0x1f, 0, adau1373_out_tlv),
SOC_DOUBLE_R_TLV("Speaker Playback Volume", ADAU1373_LSPK_OUT,
ADAU1373_RSPK_OUT, 0, 0x1f, 0, adau1373_out_tlv),
SOC_DOUBLE_R_TLV("Headphone Playback Volume", ADAU1373_LHP_OUT,
ADAU1373_RHP_OUT, 0, 0x1f, 0, adau1373_out_tlv),
SOC_DOUBLE_R_TLV("Input 1 Capture Volume", ADAU1373_AINL_CTRL(0),
ADAU1373_AINR_CTRL(0), 0, 0x1f, 0, adau1373_in_pga_tlv),
SOC_DOUBLE_R_TLV("Input 2 Capture Volume", ADAU1373_AINL_CTRL(1),
ADAU1373_AINR_CTRL(1), 0, 0x1f, 0, adau1373_in_pga_tlv),
SOC_DOUBLE_R_TLV("Input 3 Capture Volume", ADAU1373_AINL_CTRL(2),
ADAU1373_AINR_CTRL(2), 0, 0x1f, 0, adau1373_in_pga_tlv),
SOC_DOUBLE_R_TLV("Input 4 Capture Volume", ADAU1373_AINL_CTRL(3),
ADAU1373_AINR_CTRL(3), 0, 0x1f, 0, adau1373_in_pga_tlv),
SOC_SINGLE_TLV("Earpiece Playback Volume", ADAU1373_EP_CTRL, 0, 3, 0,
adau1373_ep_tlv),
SOC_DOUBLE_TLV("AIF3 Boost Playback Volume", ADAU1373_VOL_GAIN1, 4, 5,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("AIF2 Boost Playback Volume", ADAU1373_VOL_GAIN1, 2, 3,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("AIF1 Boost Playback Volume", ADAU1373_VOL_GAIN1, 0, 1,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("AIF3 Boost Capture Volume", ADAU1373_VOL_GAIN2, 4, 5,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("AIF2 Boost Capture Volume", ADAU1373_VOL_GAIN2, 2, 3,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("AIF1 Boost Capture Volume", ADAU1373_VOL_GAIN2, 0, 1,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("DMIC Boost Capture Volume", ADAU1373_VOL_GAIN3, 6, 7,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("ADC Boost Capture Volume", ADAU1373_VOL_GAIN3, 4, 5,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("DAC2 Boost Playback Volume", ADAU1373_VOL_GAIN3, 2, 3,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("DAC1 Boost Playback Volume", ADAU1373_VOL_GAIN3, 0, 1,
1, 0, adau1373_gain_boost_tlv),
SOC_DOUBLE_TLV("Input 1 Boost Capture Volume", ADAU1373_ADC_GAIN, 0, 4,
1, 0, adau1373_input_boost_tlv),
SOC_DOUBLE_TLV("Input 2 Boost Capture Volume", ADAU1373_ADC_GAIN, 1, 5,
1, 0, adau1373_input_boost_tlv),
SOC_DOUBLE_TLV("Input 3 Boost Capture Volume", ADAU1373_ADC_GAIN, 2, 6,
1, 0, adau1373_input_boost_tlv),
SOC_DOUBLE_TLV("Input 4 Boost Capture Volume", ADAU1373_ADC_GAIN, 3, 7,
1, 0, adau1373_input_boost_tlv),
SOC_DOUBLE_TLV("Speaker Boost Playback Volume", ADAU1373_LS_CTRL, 2, 3,
1, 0, adau1373_speaker_boost_tlv),
SOC_ENUM("Lineout1 LR Mux", adau1373_lineout1_lr_mux_enum),
SOC_ENUM("Speaker LR Mux", adau1373_speaker_lr_mux_enum),
SOC_ENUM("HPF Cutoff", adau1373_hpf_cutoff_enum),
SOC_DOUBLE("HPF Switch", ADAU1373_HPF_CTRL, 1, 0, 1, 0),
SOC_ENUM("HPF Channel", adau1373_hpf_channel_enum),
SOC_ENUM("Bass HPF Cutoff", adau1373_bass_hpf_cutoff_enum),
SOC_ENUM("Bass Clip Level Threshold", adau1373_bass_clip_level_enum),
SOC_ENUM("Bass LPF Cutoff", adau1373_bass_lpf_cutoff_enum),
SOC_DOUBLE("Bass Playback Switch", ADAU1373_BASS2, 0, 1, 1, 0),
SOC_SINGLE_TLV("Bass Playback Volume", ADAU1373_BASS2, 2, 7, 0,
adau1373_bass_tlv),
SOC_ENUM("Bass Channel", adau1373_bass_channel_enum),
SOC_ENUM("3D Freq", adau1373_3d_cutoff_enum),
SOC_ENUM("3D Level", adau1373_3d_level_enum),
SOC_SINGLE("3D Playback Switch", ADAU1373_3D_CTRL2, 0, 1, 0),
SOC_SINGLE_TLV("3D Playback Volume", ADAU1373_3D_CTRL2, 2, 7, 0,
adau1373_3d_tlv),
SOC_ENUM("3D Channel", adau1373_bass_channel_enum),
SOC_SINGLE("Zero Cross Switch", ADAU1373_PWDN_CTRL3, 7, 1, 0),
};
static const struct snd_kcontrol_new adau1373_lineout2_controls[] = {
SOC_DOUBLE_R_TLV("Lineout2 Playback Volume", ADAU1373_LLINE_OUT(1),
ADAU1373_RLINE_OUT(1), 0, 0x1f, 0, adau1373_out_tlv),
SOC_ENUM("Lineout2 LR Mux", adau1373_lineout2_lr_mux_enum),
};
static const struct snd_kcontrol_new adau1373_drc_controls[] = {
SOC_ENUM("DRC1 Channel", adau1373_drc1_channel_enum),
SOC_ENUM("DRC2 Channel", adau1373_drc2_channel_enum),
SOC_ENUM("DRC3 Channel", adau1373_drc3_channel_enum),
};
static int adau1373_pll_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
unsigned int pll_id = w->name[3] - '1';
unsigned int val;
if (SND_SOC_DAPM_EVENT_ON(event))
val = ADAU1373_PLL_CTRL6_PLL_EN;
else
val = 0;
regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
ADAU1373_PLL_CTRL6_PLL_EN, val);
if (SND_SOC_DAPM_EVENT_ON(event))
mdelay(5);
return 0;
}
static const char *adau1373_decimator_text[] = {
"ADC",
"DMIC1",
};
static SOC_ENUM_SINGLE_VIRT_DECL(adau1373_decimator_enum,
adau1373_decimator_text);
static const struct snd_kcontrol_new adau1373_decimator_mux =
SOC_DAPM_ENUM("Decimator Mux", adau1373_decimator_enum);
static const struct snd_kcontrol_new adau1373_left_adc_mixer_controls[] = {
SOC_DAPM_SINGLE("DAC1 Switch", ADAU1373_LADC_MIXER, 4, 1, 0),
SOC_DAPM_SINGLE("Input 4 Switch", ADAU1373_LADC_MIXER, 3, 1, 0),
SOC_DAPM_SINGLE("Input 3 Switch", ADAU1373_LADC_MIXER, 2, 1, 0),
SOC_DAPM_SINGLE("Input 2 Switch", ADAU1373_LADC_MIXER, 1, 1, 0),
SOC_DAPM_SINGLE("Input 1 Switch", ADAU1373_LADC_MIXER, 0, 1, 0),
};
static const struct snd_kcontrol_new adau1373_right_adc_mixer_controls[] = {
SOC_DAPM_SINGLE("DAC1 Switch", ADAU1373_RADC_MIXER, 4, 1, 0),
SOC_DAPM_SINGLE("Input 4 Switch", ADAU1373_RADC_MIXER, 3, 1, 0),
SOC_DAPM_SINGLE("Input 3 Switch", ADAU1373_RADC_MIXER, 2, 1, 0),
SOC_DAPM_SINGLE("Input 2 Switch", ADAU1373_RADC_MIXER, 1, 1, 0),
SOC_DAPM_SINGLE("Input 1 Switch", ADAU1373_RADC_MIXER, 0, 1, 0),
};
#define DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(_name, _reg) \
const struct snd_kcontrol_new _name[] = { \
SOC_DAPM_SINGLE("Left DAC2 Switch", _reg, 7, 1, 0), \
SOC_DAPM_SINGLE("Right DAC2 Switch", _reg, 6, 1, 0), \
SOC_DAPM_SINGLE("Left DAC1 Switch", _reg, 5, 1, 0), \
SOC_DAPM_SINGLE("Right DAC1 Switch", _reg, 4, 1, 0), \
SOC_DAPM_SINGLE("Input 4 Bypass Switch", _reg, 3, 1, 0), \
SOC_DAPM_SINGLE("Input 3 Bypass Switch", _reg, 2, 1, 0), \
SOC_DAPM_SINGLE("Input 2 Bypass Switch", _reg, 1, 1, 0), \
SOC_DAPM_SINGLE("Input 1 Bypass Switch", _reg, 0, 1, 0), \
}
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_line1_mixer_controls,
ADAU1373_LLINE1_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_line1_mixer_controls,
ADAU1373_RLINE1_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_line2_mixer_controls,
ADAU1373_LLINE2_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_line2_mixer_controls,
ADAU1373_RLINE2_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_spk_mixer_controls,
ADAU1373_LSPK_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_spk_mixer_controls,
ADAU1373_RSPK_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_ep_mixer_controls,
ADAU1373_EP_MIX);
static const struct snd_kcontrol_new adau1373_left_hp_mixer_controls[] = {
SOC_DAPM_SINGLE("Left DAC1 Switch", ADAU1373_LHP_MIX, 5, 1, 0),
SOC_DAPM_SINGLE("Left DAC2 Switch", ADAU1373_LHP_MIX, 4, 1, 0),
SOC_DAPM_SINGLE("Input 4 Bypass Switch", ADAU1373_LHP_MIX, 3, 1, 0),
SOC_DAPM_SINGLE("Input 3 Bypass Switch", ADAU1373_LHP_MIX, 2, 1, 0),
SOC_DAPM_SINGLE("Input 2 Bypass Switch", ADAU1373_LHP_MIX, 1, 1, 0),
SOC_DAPM_SINGLE("Input 1 Bypass Switch", ADAU1373_LHP_MIX, 0, 1, 0),
};
static const struct snd_kcontrol_new adau1373_right_hp_mixer_controls[] = {
SOC_DAPM_SINGLE("Right DAC1 Switch", ADAU1373_RHP_MIX, 5, 1, 0),
SOC_DAPM_SINGLE("Right DAC2 Switch", ADAU1373_RHP_MIX, 4, 1, 0),
SOC_DAPM_SINGLE("Input 4 Bypass Switch", ADAU1373_RHP_MIX, 3, 1, 0),
SOC_DAPM_SINGLE("Input 3 Bypass Switch", ADAU1373_RHP_MIX, 2, 1, 0),
SOC_DAPM_SINGLE("Input 2 Bypass Switch", ADAU1373_RHP_MIX, 1, 1, 0),
SOC_DAPM_SINGLE("Input 1 Bypass Switch", ADAU1373_RHP_MIX, 0, 1, 0),
};
#define DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(_name, _reg) \
const struct snd_kcontrol_new _name[] = { \
SOC_DAPM_SINGLE("DMIC2 Swapped Switch", _reg, 6, 1, 0), \
SOC_DAPM_SINGLE("DMIC2 Switch", _reg, 5, 1, 0), \
SOC_DAPM_SINGLE("ADC/DMIC1 Swapped Switch", _reg, 4, 1, 0), \
SOC_DAPM_SINGLE("ADC/DMIC1 Switch", _reg, 3, 1, 0), \
SOC_DAPM_SINGLE("AIF3 Switch", _reg, 2, 1, 0), \
SOC_DAPM_SINGLE("AIF2 Switch", _reg, 1, 1, 0), \
SOC_DAPM_SINGLE("AIF1 Switch", _reg, 0, 1, 0), \
}
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel1_mixer_controls,
ADAU1373_DIN_MIX_CTRL(0));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel2_mixer_controls,
ADAU1373_DIN_MIX_CTRL(1));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel3_mixer_controls,
ADAU1373_DIN_MIX_CTRL(2));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel4_mixer_controls,
ADAU1373_DIN_MIX_CTRL(3));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel5_mixer_controls,
ADAU1373_DIN_MIX_CTRL(4));
#define DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(_name, _reg) \
const struct snd_kcontrol_new _name[] = { \
SOC_DAPM_SINGLE("DSP Channel5 Switch", _reg, 4, 1, 0), \
SOC_DAPM_SINGLE("DSP Channel4 Switch", _reg, 3, 1, 0), \
SOC_DAPM_SINGLE("DSP Channel3 Switch", _reg, 2, 1, 0), \
SOC_DAPM_SINGLE("DSP Channel2 Switch", _reg, 1, 1, 0), \
SOC_DAPM_SINGLE("DSP Channel1 Switch", _reg, 0, 1, 0), \
}
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif1_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(0));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif2_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(1));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif3_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(2));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_dac1_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(3));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_dac2_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(4));
static const struct snd_soc_dapm_widget adau1373_dapm_widgets[] = {
/* Datasheet claims Left ADC is bit 6 and Right ADC is bit 7, but that
* doesn't seem to be the case. */
SND_SOC_DAPM_ADC("Left ADC", NULL, ADAU1373_PWDN_CTRL1, 7, 0),
SND_SOC_DAPM_ADC("Right ADC", NULL, ADAU1373_PWDN_CTRL1, 6, 0),
SND_SOC_DAPM_ADC("DMIC1", NULL, ADAU1373_DIGMICCTRL, 0, 0),
SND_SOC_DAPM_ADC("DMIC2", NULL, ADAU1373_DIGMICCTRL, 2, 0),
SND_SOC_DAPM_MUX("Decimator Mux", SND_SOC_NOPM, 0, 0,
&adau1373_decimator_mux),
SND_SOC_DAPM_SUPPLY("MICBIAS2", ADAU1373_PWDN_CTRL1, 5, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("MICBIAS1", ADAU1373_PWDN_CTRL1, 4, 0, NULL, 0),
SND_SOC_DAPM_PGA("IN4PGA", ADAU1373_PWDN_CTRL1, 3, 0, NULL, 0),
SND_SOC_DAPM_PGA("IN3PGA", ADAU1373_PWDN_CTRL1, 2, 0, NULL, 0),
SND_SOC_DAPM_PGA("IN2PGA", ADAU1373_PWDN_CTRL1, 1, 0, NULL, 0),
SND_SOC_DAPM_PGA("IN1PGA", ADAU1373_PWDN_CTRL1, 0, 0, NULL, 0),
SND_SOC_DAPM_DAC("Left DAC2", NULL, ADAU1373_PWDN_CTRL2, 7, 0),
SND_SOC_DAPM_DAC("Right DAC2", NULL, ADAU1373_PWDN_CTRL2, 6, 0),
SND_SOC_DAPM_DAC("Left DAC1", NULL, ADAU1373_PWDN_CTRL2, 5, 0),
SND_SOC_DAPM_DAC("Right DAC1", NULL, ADAU1373_PWDN_CTRL2, 4, 0),
SOC_MIXER_ARRAY("Left ADC Mixer", SND_SOC_NOPM, 0, 0,
adau1373_left_adc_mixer_controls),
SOC_MIXER_ARRAY("Right ADC Mixer", SND_SOC_NOPM, 0, 0,
adau1373_right_adc_mixer_controls),
SOC_MIXER_ARRAY("Left Lineout2 Mixer", ADAU1373_PWDN_CTRL2, 3, 0,
adau1373_left_line2_mixer_controls),
SOC_MIXER_ARRAY("Right Lineout2 Mixer", ADAU1373_PWDN_CTRL2, 2, 0,
adau1373_right_line2_mixer_controls),
SOC_MIXER_ARRAY("Left Lineout1 Mixer", ADAU1373_PWDN_CTRL2, 1, 0,
adau1373_left_line1_mixer_controls),
SOC_MIXER_ARRAY("Right Lineout1 Mixer", ADAU1373_PWDN_CTRL2, 0, 0,
adau1373_right_line1_mixer_controls),
SOC_MIXER_ARRAY("Earpiece Mixer", ADAU1373_PWDN_CTRL3, 4, 0,
adau1373_ep_mixer_controls),
SOC_MIXER_ARRAY("Left Speaker Mixer", ADAU1373_PWDN_CTRL3, 3, 0,
adau1373_left_spk_mixer_controls),
SOC_MIXER_ARRAY("Right Speaker Mixer", ADAU1373_PWDN_CTRL3, 2, 0,
adau1373_right_spk_mixer_controls),
SOC_MIXER_ARRAY("Left Headphone Mixer", SND_SOC_NOPM, 0, 0,
adau1373_left_hp_mixer_controls),
SOC_MIXER_ARRAY("Right Headphone Mixer", SND_SOC_NOPM, 0, 0,
adau1373_right_hp_mixer_controls),
SND_SOC_DAPM_SUPPLY("Headphone Enable", ADAU1373_PWDN_CTRL3, 1, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF1 CLK", ADAU1373_SRC_DAI_CTRL(0), 0, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF2 CLK", ADAU1373_SRC_DAI_CTRL(1), 0, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF3 CLK", ADAU1373_SRC_DAI_CTRL(2), 0, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF1 IN SRC", ADAU1373_SRC_DAI_CTRL(0), 2, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF1 OUT SRC", ADAU1373_SRC_DAI_CTRL(0), 1, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF2 IN SRC", ADAU1373_SRC_DAI_CTRL(1), 2, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF2 OUT SRC", ADAU1373_SRC_DAI_CTRL(1), 1, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF3 IN SRC", ADAU1373_SRC_DAI_CTRL(2), 2, 0,
NULL, 0),
SND_SOC_DAPM_SUPPLY("AIF3 OUT SRC", ADAU1373_SRC_DAI_CTRL(2), 1, 0,
NULL, 0),
SND_SOC_DAPM_AIF_IN("AIF1 IN", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_OUT("AIF1 OUT", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("AIF2 IN", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_OUT("AIF2 OUT", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_IN("AIF3 IN", "AIF3 Playback", 0, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_AIF_OUT("AIF3 OUT", "AIF3 Capture", 0, SND_SOC_NOPM, 0, 0),
SOC_MIXER_ARRAY("DSP Channel1 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dsp_channel1_mixer_controls),
SOC_MIXER_ARRAY("DSP Channel2 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dsp_channel2_mixer_controls),
SOC_MIXER_ARRAY("DSP Channel3 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dsp_channel3_mixer_controls),
SOC_MIXER_ARRAY("DSP Channel4 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dsp_channel4_mixer_controls),
SOC_MIXER_ARRAY("DSP Channel5 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dsp_channel5_mixer_controls),
SOC_MIXER_ARRAY("AIF1 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_aif1_mixer_controls),
SOC_MIXER_ARRAY("AIF2 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_aif2_mixer_controls),
SOC_MIXER_ARRAY("AIF3 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_aif3_mixer_controls),
SOC_MIXER_ARRAY("DAC1 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dac1_mixer_controls),
SOC_MIXER_ARRAY("DAC2 Mixer", SND_SOC_NOPM, 0, 0,
adau1373_dac2_mixer_controls),
SND_SOC_DAPM_SUPPLY("DSP", ADAU1373_DIGEN, 4, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Recording Engine B", ADAU1373_DIGEN, 3, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Recording Engine A", ADAU1373_DIGEN, 2, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Playback Engine B", ADAU1373_DIGEN, 1, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("Playback Engine A", ADAU1373_DIGEN, 0, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("PLL1", SND_SOC_NOPM, 0, 0, adau1373_pll_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("PLL2", SND_SOC_NOPM, 0, 0, adau1373_pll_event,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("SYSCLK1", ADAU1373_CLK_SRC_DIV(0), 7, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY("SYSCLK2", ADAU1373_CLK_SRC_DIV(1), 7, 0, NULL, 0),
SND_SOC_DAPM_INPUT("AIN1L"),
SND_SOC_DAPM_INPUT("AIN1R"),
SND_SOC_DAPM_INPUT("AIN2L"),
SND_SOC_DAPM_INPUT("AIN2R"),
SND_SOC_DAPM_INPUT("AIN3L"),
SND_SOC_DAPM_INPUT("AIN3R"),
SND_SOC_DAPM_INPUT("AIN4L"),
SND_SOC_DAPM_INPUT("AIN4R"),
SND_SOC_DAPM_INPUT("DMIC1DAT"),
SND_SOC_DAPM_INPUT("DMIC2DAT"),
SND_SOC_DAPM_OUTPUT("LOUT1L"),
SND_SOC_DAPM_OUTPUT("LOUT1R"),
SND_SOC_DAPM_OUTPUT("LOUT2L"),
SND_SOC_DAPM_OUTPUT("LOUT2R"),
SND_SOC_DAPM_OUTPUT("HPL"),
SND_SOC_DAPM_OUTPUT("HPR"),
SND_SOC_DAPM_OUTPUT("SPKL"),
SND_SOC_DAPM_OUTPUT("SPKR"),
SND_SOC_DAPM_OUTPUT("EP"),
};
static int adau1373_check_aif_clk(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
unsigned int dai;
const char *clk;
dai = sink->name[3] - '1';
if (!adau1373->dais[dai].master)
return 0;
if (adau1373->dais[dai].clk_src == ADAU1373_CLK_SRC_PLL1)
clk = "SYSCLK1";
else
clk = "SYSCLK2";
return strcmp(source->name, clk) == 0;
}
static int adau1373_check_src(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
unsigned int dai;
dai = sink->name[3] - '1';
return adau1373->dais[dai].enable_src;
}
#define DSP_CHANNEL_MIXER_ROUTES(_sink) \
{ _sink, "DMIC2 Swapped Switch", "DMIC2" }, \
{ _sink, "DMIC2 Switch", "DMIC2" }, \
{ _sink, "ADC/DMIC1 Swapped Switch", "Decimator Mux" }, \
{ _sink, "ADC/DMIC1 Switch", "Decimator Mux" }, \
{ _sink, "AIF1 Switch", "AIF1 IN" }, \
{ _sink, "AIF2 Switch", "AIF2 IN" }, \
{ _sink, "AIF3 Switch", "AIF3 IN" }
#define DSP_OUTPUT_MIXER_ROUTES(_sink) \
{ _sink, "DSP Channel1 Switch", "DSP Channel1 Mixer" }, \
{ _sink, "DSP Channel2 Switch", "DSP Channel2 Mixer" }, \
{ _sink, "DSP Channel3 Switch", "DSP Channel3 Mixer" }, \
{ _sink, "DSP Channel4 Switch", "DSP Channel4 Mixer" }, \
{ _sink, "DSP Channel5 Switch", "DSP Channel5 Mixer" }
#define LEFT_OUTPUT_MIXER_ROUTES(_sink) \
{ _sink, "Right DAC2 Switch", "Right DAC2" }, \
{ _sink, "Left DAC2 Switch", "Left DAC2" }, \
{ _sink, "Right DAC1 Switch", "Right DAC1" }, \
{ _sink, "Left DAC1 Switch", "Left DAC1" }, \
{ _sink, "Input 1 Bypass Switch", "IN1PGA" }, \
{ _sink, "Input 2 Bypass Switch", "IN2PGA" }, \
{ _sink, "Input 3 Bypass Switch", "IN3PGA" }, \
{ _sink, "Input 4 Bypass Switch", "IN4PGA" }
#define RIGHT_OUTPUT_MIXER_ROUTES(_sink) \
{ _sink, "Right DAC2 Switch", "Right DAC2" }, \
{ _sink, "Left DAC2 Switch", "Left DAC2" }, \
{ _sink, "Right DAC1 Switch", "Right DAC1" }, \
{ _sink, "Left DAC1 Switch", "Left DAC1" }, \
{ _sink, "Input 1 Bypass Switch", "IN1PGA" }, \
{ _sink, "Input 2 Bypass Switch", "IN2PGA" }, \
{ _sink, "Input 3 Bypass Switch", "IN3PGA" }, \
{ _sink, "Input 4 Bypass Switch", "IN4PGA" }
static const struct snd_soc_dapm_route adau1373_dapm_routes[] = {
{ "Left ADC Mixer", "DAC1 Switch", "Left DAC1" },
{ "Left ADC Mixer", "Input 1 Switch", "IN1PGA" },
{ "Left ADC Mixer", "Input 2 Switch", "IN2PGA" },
{ "Left ADC Mixer", "Input 3 Switch", "IN3PGA" },
{ "Left ADC Mixer", "Input 4 Switch", "IN4PGA" },
{ "Right ADC Mixer", "DAC1 Switch", "Right DAC1" },
{ "Right ADC Mixer", "Input 1 Switch", "IN1PGA" },
{ "Right ADC Mixer", "Input 2 Switch", "IN2PGA" },
{ "Right ADC Mixer", "Input 3 Switch", "IN3PGA" },
{ "Right ADC Mixer", "Input 4 Switch", "IN4PGA" },
{ "Left ADC", NULL, "Left ADC Mixer" },
{ "Right ADC", NULL, "Right ADC Mixer" },
{ "Decimator Mux", "ADC", "Left ADC" },
{ "Decimator Mux", "ADC", "Right ADC" },
{ "Decimator Mux", "DMIC1", "DMIC1" },
DSP_CHANNEL_MIXER_ROUTES("DSP Channel1 Mixer"),
DSP_CHANNEL_MIXER_ROUTES("DSP Channel2 Mixer"),
DSP_CHANNEL_MIXER_ROUTES("DSP Channel3 Mixer"),
DSP_CHANNEL_MIXER_ROUTES("DSP Channel4 Mixer"),
DSP_CHANNEL_MIXER_ROUTES("DSP Channel5 Mixer"),
DSP_OUTPUT_MIXER_ROUTES("AIF1 Mixer"),
DSP_OUTPUT_MIXER_ROUTES("AIF2 Mixer"),
DSP_OUTPUT_MIXER_ROUTES("AIF3 Mixer"),
DSP_OUTPUT_MIXER_ROUTES("DAC1 Mixer"),
DSP_OUTPUT_MIXER_ROUTES("DAC2 Mixer"),
{ "AIF1 OUT", NULL, "AIF1 Mixer" },
{ "AIF2 OUT", NULL, "AIF2 Mixer" },
{ "AIF3 OUT", NULL, "AIF3 Mixer" },
{ "Left DAC1", NULL, "DAC1 Mixer" },
{ "Right DAC1", NULL, "DAC1 Mixer" },
{ "Left DAC2", NULL, "DAC2 Mixer" },
{ "Right DAC2", NULL, "DAC2 Mixer" },
LEFT_OUTPUT_MIXER_ROUTES("Left Lineout1 Mixer"),
RIGHT_OUTPUT_MIXER_ROUTES("Right Lineout1 Mixer"),
LEFT_OUTPUT_MIXER_ROUTES("Left Lineout2 Mixer"),
RIGHT_OUTPUT_MIXER_ROUTES("Right Lineout2 Mixer"),
LEFT_OUTPUT_MIXER_ROUTES("Left Speaker Mixer"),
RIGHT_OUTPUT_MIXER_ROUTES("Right Speaker Mixer"),
{ "Left Headphone Mixer", "Left DAC2 Switch", "Left DAC2" },
{ "Left Headphone Mixer", "Left DAC1 Switch", "Left DAC1" },
{ "Left Headphone Mixer", "Input 1 Bypass Switch", "IN1PGA" },
{ "Left Headphone Mixer", "Input 2 Bypass Switch", "IN2PGA" },
{ "Left Headphone Mixer", "Input 3 Bypass Switch", "IN3PGA" },
{ "Left Headphone Mixer", "Input 4 Bypass Switch", "IN4PGA" },
{ "Right Headphone Mixer", "Right DAC2 Switch", "Right DAC2" },
{ "Right Headphone Mixer", "Right DAC1 Switch", "Right DAC1" },
{ "Right Headphone Mixer", "Input 1 Bypass Switch", "IN1PGA" },
{ "Right Headphone Mixer", "Input 2 Bypass Switch", "IN2PGA" },
{ "Right Headphone Mixer", "Input 3 Bypass Switch", "IN3PGA" },
{ "Right Headphone Mixer", "Input 4 Bypass Switch", "IN4PGA" },
{ "Left Headphone Mixer", NULL, "Headphone Enable" },
{ "Right Headphone Mixer", NULL, "Headphone Enable" },
{ "Earpiece Mixer", "Right DAC2 Switch", "Right DAC2" },
{ "Earpiece Mixer", "Left DAC2 Switch", "Left DAC2" },
{ "Earpiece Mixer", "Right DAC1 Switch", "Right DAC1" },
{ "Earpiece Mixer", "Left DAC1 Switch", "Left DAC1" },
{ "Earpiece Mixer", "Input 1 Bypass Switch", "IN1PGA" },
{ "Earpiece Mixer", "Input 2 Bypass Switch", "IN2PGA" },
{ "Earpiece Mixer", "Input 3 Bypass Switch", "IN3PGA" },
{ "Earpiece Mixer", "Input 4 Bypass Switch", "IN4PGA" },
{ "LOUT1L", NULL, "Left Lineout1 Mixer" },
{ "LOUT1R", NULL, "Right Lineout1 Mixer" },
{ "LOUT2L", NULL, "Left Lineout2 Mixer" },
{ "LOUT2R", NULL, "Right Lineout2 Mixer" },
{ "SPKL", NULL, "Left Speaker Mixer" },
{ "SPKR", NULL, "Right Speaker Mixer" },
{ "HPL", NULL, "Left Headphone Mixer" },
{ "HPR", NULL, "Right Headphone Mixer" },
{ "EP", NULL, "Earpiece Mixer" },
{ "IN1PGA", NULL, "AIN1L" },
{ "IN2PGA", NULL, "AIN2L" },
{ "IN3PGA", NULL, "AIN3L" },
{ "IN4PGA", NULL, "AIN4L" },
{ "IN1PGA", NULL, "AIN1R" },
{ "IN2PGA", NULL, "AIN2R" },
{ "IN3PGA", NULL, "AIN3R" },
{ "IN4PGA", NULL, "AIN4R" },
{ "SYSCLK1", NULL, "PLL1" },
{ "SYSCLK2", NULL, "PLL2" },
{ "Left DAC1", NULL, "SYSCLK1" },
{ "Right DAC1", NULL, "SYSCLK1" },
{ "Left DAC2", NULL, "SYSCLK1" },
{ "Right DAC2", NULL, "SYSCLK1" },
{ "Left ADC", NULL, "SYSCLK1" },
{ "Right ADC", NULL, "SYSCLK1" },
{ "DSP", NULL, "SYSCLK1" },
{ "AIF1 Mixer", NULL, "DSP" },
{ "AIF2 Mixer", NULL, "DSP" },
{ "AIF3 Mixer", NULL, "DSP" },
{ "DAC1 Mixer", NULL, "DSP" },
{ "DAC2 Mixer", NULL, "DSP" },
{ "DAC1 Mixer", NULL, "Playback Engine A" },
{ "DAC2 Mixer", NULL, "Playback Engine B" },
{ "Left ADC Mixer", NULL, "Recording Engine A" },
{ "Right ADC Mixer", NULL, "Recording Engine A" },
{ "AIF1 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
{ "AIF2 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
{ "AIF3 CLK", NULL, "SYSCLK1", adau1373_check_aif_clk },
{ "AIF1 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
{ "AIF2 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
{ "AIF3 CLK", NULL, "SYSCLK2", adau1373_check_aif_clk },
{ "AIF1 IN", NULL, "AIF1 CLK" },
{ "AIF1 OUT", NULL, "AIF1 CLK" },
{ "AIF2 IN", NULL, "AIF2 CLK" },
{ "AIF2 OUT", NULL, "AIF2 CLK" },
{ "AIF3 IN", NULL, "AIF3 CLK" },
{ "AIF3 OUT", NULL, "AIF3 CLK" },
{ "AIF1 IN", NULL, "AIF1 IN SRC", adau1373_check_src },
{ "AIF1 OUT", NULL, "AIF1 OUT SRC", adau1373_check_src },
{ "AIF2 IN", NULL, "AIF2 IN SRC", adau1373_check_src },
{ "AIF2 OUT", NULL, "AIF2 OUT SRC", adau1373_check_src },
{ "AIF3 IN", NULL, "AIF3 IN SRC", adau1373_check_src },
{ "AIF3 OUT", NULL, "AIF3 OUT SRC", adau1373_check_src },
{ "DMIC1", NULL, "DMIC1DAT" },
{ "DMIC1", NULL, "SYSCLK1" },
{ "DMIC1", NULL, "Recording Engine A" },
{ "DMIC2", NULL, "DMIC2DAT" },
{ "DMIC2", NULL, "SYSCLK1" },
{ "DMIC2", NULL, "Recording Engine B" },
};
static int adau1373_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{
struct snd_soc_component *component = dai->component;
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id];
unsigned int div;
unsigned int freq;
unsigned int ctrl;
freq = adau1373_dai->sysclk;
if (freq % params_rate(params) != 0)
return -EINVAL;
switch (freq / params_rate(params)) {
case 1024: /* sysclk / 256 */
div = 0;
break;
case 1536: /* 2/3 sysclk / 256 */
div = 1;
break;
case 2048: /* 1/2 sysclk / 256 */
div = 2;
break;
case 3072: /* 1/3 sysclk / 256 */
div = 3;
break;
case 4096: /* 1/4 sysclk / 256 */
div = 4;
break;
case 6144: /* 1/6 sysclk / 256 */
div = 5;
break;
case 5632: /* 2/11 sysclk / 256 */
div = 6;
break;
default:
return -EINVAL;
}
adau1373_dai->enable_src = (div != 0);
regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id),
ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK,
(div << 2) | ADAU1373_BCLKDIV_64);
switch (params_width(params)) {
case 16:
ctrl = ADAU1373_DAI_WLEN_16;
break;
case 20:
ctrl = ADAU1373_DAI_WLEN_20;
break;
case 24:
ctrl = ADAU1373_DAI_WLEN_24;
break;
case 32:
ctrl = ADAU1373_DAI_WLEN_32;
break;
default:
return -EINVAL;
}
return regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id),
ADAU1373_DAI_WLEN_MASK, ctrl);
}
static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
struct snd_soc_component *component = dai->component;
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id];
unsigned int ctrl;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM:
ctrl = ADAU1373_DAI_MASTER;
adau1373_dai->master = true;
break;
case SND_SOC_DAIFMT_CBS_CFS:
ctrl = 0;
adau1373_dai->master = false;
break;
default:
return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
ctrl |= ADAU1373_DAI_FORMAT_I2S;
break;
case SND_SOC_DAIFMT_LEFT_J:
ctrl |= ADAU1373_DAI_FORMAT_LEFT_J;
break;
case SND_SOC_DAIFMT_RIGHT_J:
ctrl |= ADAU1373_DAI_FORMAT_RIGHT_J;
break;
case SND_SOC_DAIFMT_DSP_B:
ctrl |= ADAU1373_DAI_FORMAT_DSP;
break;
default:
return -EINVAL;
}
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
break;
case SND_SOC_DAIFMT_IB_NF:
ctrl |= ADAU1373_DAI_INVERT_BCLK;
break;
case SND_SOC_DAIFMT_NB_IF:
ctrl |= ADAU1373_DAI_INVERT_LRCLK;
break;
case SND_SOC_DAIFMT_IB_IF:
ctrl |= ADAU1373_DAI_INVERT_LRCLK | ADAU1373_DAI_INVERT_BCLK;
break;
default:
return -EINVAL;
}
regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id),
~ADAU1373_DAI_WLEN_MASK, ctrl);
return 0;
}
static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
{
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(dai->component);
struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id];
switch (clk_id) {
case ADAU1373_CLK_SRC_PLL1:
case ADAU1373_CLK_SRC_PLL2:
break;
default:
return -EINVAL;
}
adau1373_dai->sysclk = freq;
adau1373_dai->clk_src = clk_id;
regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id),
ADAU1373_BCLKDIV_SOURCE, clk_id << 5);
return 0;
}
static const struct snd_soc_dai_ops adau1373_dai_ops = {
.hw_params = adau1373_hw_params,
.set_sysclk = adau1373_set_dai_sysclk,
.set_fmt = adau1373_set_dai_fmt,
};
#define ADAU1373_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
static struct snd_soc_dai_driver adau1373_dai_driver[] = {
{
.id = 0,
.name = "adau1373-aif1",
.playback = {
.stream_name = "AIF1 Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.capture = {
.stream_name = "AIF1 Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.ops = &adau1373_dai_ops,
.symmetric_rates = 1,
},
{
.id = 1,
.name = "adau1373-aif2",
.playback = {
.stream_name = "AIF2 Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.capture = {
.stream_name = "AIF2 Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.ops = &adau1373_dai_ops,
.symmetric_rates = 1,
},
{
.id = 2,
.name = "adau1373-aif3",
.playback = {
.stream_name = "AIF3 Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.capture = {
.stream_name = "AIF3 Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_48000,
.formats = ADAU1373_FORMATS,
},
.ops = &adau1373_dai_ops,
.symmetric_rates = 1,
},
};
static int adau1373_set_pll(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out)
{
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
unsigned int dpll_div = 0;
uint8_t pll_regs[5];
int ret;
switch (pll_id) {
case ADAU1373_PLL1:
case ADAU1373_PLL2:
break;
default:
return -EINVAL;
}
switch (source) {
case ADAU1373_PLL_SRC_BCLK1:
case ADAU1373_PLL_SRC_BCLK2:
case ADAU1373_PLL_SRC_BCLK3:
case ADAU1373_PLL_SRC_LRCLK1:
case ADAU1373_PLL_SRC_LRCLK2:
case ADAU1373_PLL_SRC_LRCLK3:
case ADAU1373_PLL_SRC_MCLK1:
case ADAU1373_PLL_SRC_MCLK2:
case ADAU1373_PLL_SRC_GPIO1:
case ADAU1373_PLL_SRC_GPIO2:
case ADAU1373_PLL_SRC_GPIO3:
case ADAU1373_PLL_SRC_GPIO4:
break;
default:
return -EINVAL;
}
if (freq_in < 7813 || freq_in > 27000000)
return -EINVAL;
if (freq_out < 45158000 || freq_out > 49152000)
return -EINVAL;
/* APLL input needs to be >= 8Mhz, so in case freq_in is less we use the
* DPLL to get it there. DPLL_out = (DPLL_in / div) * 1024 */
while (freq_in < 8000000) {
freq_in *= 2;
dpll_div++;
}
ret = adau_calc_pll_cfg(freq_in, freq_out, pll_regs);
if (ret)
return -EINVAL;
if (dpll_div) {
dpll_div = 11 - dpll_div;
regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
ADAU1373_PLL_CTRL6_DPLL_BYPASS, 0);
} else {
regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id),
ADAU1373_PLL_CTRL6_DPLL_BYPASS,
ADAU1373_PLL_CTRL6_DPLL_BYPASS);
}
regmap_write(adau1373->regmap, ADAU1373_DPLL_CTRL(pll_id),
(source << 4) | dpll_div);
regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL1(pll_id), pll_regs[0]);
regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL2(pll_id), pll_regs[1]);
regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL3(pll_id), pll_regs[2]);
regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL4(pll_id), pll_regs[3]);
regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL5(pll_id), pll_regs[4]);
/* Set sysclk to pll_rate / 4 */
regmap_update_bits(adau1373->regmap, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09);
return 0;
}
static void adau1373_load_drc_settings(struct adau1373 *adau1373,
unsigned int nr, uint8_t *drc)
{
unsigned int i;
for (i = 0; i < ADAU1373_DRC_SIZE; ++i)
regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]);
}
static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias)
{
switch (micbias) {
case ADAU1373_MICBIAS_2_9V:
case ADAU1373_MICBIAS_2_2V:
case ADAU1373_MICBIAS_2_6V:
case ADAU1373_MICBIAS_1_8V:
return true;
default:
break;
}
return false;
}
static int adau1373_probe(struct snd_soc_component *component)
{
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
struct adau1373_platform_data *pdata = component->dev->platform_data;
bool lineout_differential = false;
unsigned int val;
int i;
if (pdata) {
if (pdata->num_drc > ARRAY_SIZE(pdata->drc_setting))
return -EINVAL;
if (!adau1373_valid_micbias(pdata->micbias1) ||
!adau1373_valid_micbias(pdata->micbias2))
return -EINVAL;
for (i = 0; i < pdata->num_drc; ++i) {
adau1373_load_drc_settings(adau1373, i,
pdata->drc_setting[i]);
}
snd_soc_add_component_controls(component, adau1373_drc_controls,
pdata->num_drc);
val = 0;
for (i = 0; i < 4; ++i) {
if (pdata->input_differential[i])
val |= BIT(i);
}
regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val);
val = 0;
if (pdata->lineout_differential)
val |= ADAU1373_OUTPUT_CTRL_LDIFF;
if (pdata->lineout_ground_sense)
val |= ADAU1373_OUTPUT_CTRL_LNFBEN;
regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val);
lineout_differential = pdata->lineout_differential;
regmap_write(adau1373->regmap, ADAU1373_EP_CTRL,
(pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) |
(pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET));
}
if (!lineout_differential) {
snd_soc_add_component_controls(component, adau1373_lineout2_controls,
ARRAY_SIZE(adau1373_lineout2_controls));
}
regmap_write(adau1373->regmap, ADAU1373_ADC_CTRL,
ADAU1373_ADC_CTRL_RESET_FORCE | ADAU1373_ADC_CTRL_PEAK_DETECT);
return 0;
}
static int adau1373_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
switch (level) {
case SND_SOC_BIAS_ON:
break;
case SND_SOC_BIAS_PREPARE:
break;
case SND_SOC_BIAS_STANDBY:
regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3,
ADAU1373_PWDN_CTRL3_PWR_EN, ADAU1373_PWDN_CTRL3_PWR_EN);
break;
case SND_SOC_BIAS_OFF:
regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3,
ADAU1373_PWDN_CTRL3_PWR_EN, 0);
break;
}
return 0;
}
static int adau1373_resume(struct snd_soc_component *component)
{
struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component);
regcache_sync(adau1373->regmap);
return 0;
}
static bool adau1373_register_volatile(struct device *dev, unsigned int reg)
{
switch (reg) {
case ADAU1373_SOFT_RESET:
case ADAU1373_ADC_DAC_STATUS:
return true;
default:
return false;
}
}
static const struct regmap_config adau1373_regmap_config = {
.val_bits = 8,
.reg_bits = 8,
.volatile_reg = adau1373_register_volatile,
.max_register = ADAU1373_SOFT_RESET,
.cache_type = REGCACHE_RBTREE,
.reg_defaults = adau1373_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults),
};
static const struct snd_soc_component_driver adau1373_component_driver = {
.probe = adau1373_probe,
.resume = adau1373_resume,
.set_bias_level = adau1373_set_bias_level,
.set_pll = adau1373_set_pll,
.controls = adau1373_controls,
.num_controls = ARRAY_SIZE(adau1373_controls),
.dapm_widgets = adau1373_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(adau1373_dapm_widgets),
.dapm_routes = adau1373_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(adau1373_dapm_routes),
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
};
static int adau1373_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct adau1373 *adau1373;
int ret;
adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL);
if (!adau1373)
return -ENOMEM;
adau1373->regmap = devm_regmap_init_i2c(client,
&adau1373_regmap_config);
if (IS_ERR(adau1373->regmap))
return PTR_ERR(adau1373->regmap);
regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00);
dev_set_drvdata(&client->dev, adau1373);
ret = devm_snd_soc_register_component(&client->dev,
&adau1373_component_driver,
adau1373_dai_driver, ARRAY_SIZE(adau1373_dai_driver));
return ret;
}
static const struct i2c_device_id adau1373_i2c_id[] = {
{ "adau1373", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adau1373_i2c_id);
static struct i2c_driver adau1373_i2c_driver = {
.driver = {
.name = "adau1373",
},
.probe = adau1373_i2c_probe,
.id_table = adau1373_i2c_id,
};
module_i2c_driver(adau1373_i2c_driver);
MODULE_DESCRIPTION("ASoC ADAU1373 driver");
MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");
MODULE_LICENSE("GPL");
| {
"pile_set_name": "Github"
} |
+++
title = "Shortcodes"
description = ""
date = "2017-04-24T18:36:24+02:00"
weight = 30
+++
A bunch of Shortcodes are available with this theme :
{{%children style="card" description="true" %}}
| {
"pile_set_name": "Github"
} |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System.Text.Json;
using Azure.Core;
namespace Azure.AI.TextAnalytics
{
public partial struct TextDocumentStatistics
{
internal static TextDocumentStatistics DeserializeTextDocumentStatistics(JsonElement element)
{
int charactersCount = default;
int transactionsCount = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("charactersCount"))
{
charactersCount = property.Value.GetInt32();
continue;
}
if (property.NameEquals("transactionsCount"))
{
transactionsCount = property.Value.GetInt32();
continue;
}
}
return new TextDocumentStatistics(charactersCount, transactionsCount);
}
}
}
| {
"pile_set_name": "Github"
} |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CrossPlatformApp.Net4
{
using Core;
class Program
{
static void Main(string[] args)
{
var thingy = new Class1();
Console.WriteLine(thingy);
}
}
}
| {
"pile_set_name": "Github"
} |
MaxID:1
0:Wir haben die letzte Bastion der Rebellen erreicht.|Kein Abtrünniger, kein Verräter und kein Rebell dürfen überleben! Die Schlacht ist erst beendet, wenn die letzte verdorbene Seele dieses Land für immer verlassen hat!
1:Der Feind naht. Ergreift zum letzten Male das Schwert und zeigt keine Gnade vor den Rebellen!|In den Kampf!
| {
"pile_set_name": "Github"
} |
<?php
class ModelApplicationInterface extends Model {
public function addInterface($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "interface` SET type = '" . $this->db->escape($data['type']) . "', username = '" . $this->db->escape($data['username']) . "', `secret` = '" . $this->db->escape($data['secret']) . "', status = '" . (int)$data['status'] . "', date_added = NOW(), date_modified = NOW()");
$interface_id = $this->db->getLastId();
return $interface_id;
}
public function editInterface($interface_id, $data) {
$this->db->query("UPDATE `" . DB_PREFIX . "interface` SET type = '" . $this->db->escape($data['type']) . "', username = '" . $this->db->escape($data['username']) . "', `secret` = '" . $this->db->escape($data['secret']) . "', status = '" . (int)$data['status'] . "', date_modified = NOW() WHERE interface_id = '" . (int)$interface_id . "'");
}
public function deleteInterface($interface_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "interface` WHERE interface_id = '" . (int)$interface_id . "'");
}
public function getInterface($interface_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "interface` WHERE interface_id = '" . (int)$interface_id . "'");
return $query->row;
}
public function getInterfaces($data = array()) {
$sql = "SELECT * FROM `" . DB_PREFIX . "interface`";
$sort_data = array(
'type',
'username',
'status',
'date_added',
'date_modified'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY type";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalInterfaces() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "interface`");
return $query->row['total'];
}
}
| {
"pile_set_name": "Github"
} |
In this directory, we created a velocity profile with unif2
and apply velconv to convert this velocity profile, considered
now as a v(x,t) function, into different types.
If you are new to SU, start by reading "The SU User's Manual" and the
README in $CWPROOT/src/demos.
The X demos pop up several examples. These demo scripts are
meant to be READ. Then you can clone what you need for your
application.
XVelconv build a velocity profile and perform velocity
conversions with velconv
John Stockwell | [email protected]
Center for Wave Phenomena (The Home of Seismic Un*x)
Colorado School of Mines
Golden, CO 80401 | http://www.cwp.mines.edu/cwpcodes
voice: (303) 273-3049 | fax: (303) 273-3478.
| {
"pile_set_name": "Github"
} |
#!/bin/bash
# This file is licensed under the MIT License (MIT) available on
# http://opensource.org/licenses/MIT.
PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin
AUTHORIZED_SIGNERS_DIR='/bitcoin.org/auto-build-committers.gnupg'
REPO='https://github.com/bitcoin-dot-org/bitcoin.org.git'
BUNDLE_DIR='/bitcoin.org/bundle'
SITEDIR='/bitcoin.org/site'
DESTDIR='build@bitcoinorgsite:/var/www/site'
WORKDIR=`mktemp -d`
BITCOINORG_BUILD_TYPE='deployment'
export BUNDLE_DIR
export BITCOINORG_BUILD_TYPE
# Stop script in case a single command fails
set -e
# Cleanup on EXIT and kill all subprocesses (even when a command fails)
trap "rm -rf $WORKDIR; kill 0; exit 1;" EXIT
trap "rm -rf $WORKDIR; kill 0;" SIGINT
# Clone repository if missing
if [ ! -d $SITEDIR ]; then
git clone $REPO $SITEDIR
cd $SITEDIR
git reset --hard HEAD~1
fi
# Exit if no new commit is available
cd $SITEDIR
git fetch -a
LASTLOCALCOMMIT=`git log --format="%H" | head -n1`
LASTREMOTECOMMIT=`git log origin/master --format="%H" | head -n1`
if [ $LASTLOCALCOMMIT == $LASTREMOTECOMMIT ]; then
exit
fi
# Update local branch
git reset --hard origin/master
git clean -x -f -d
## Whether to auto-build or force-build
case "${1:-nil}" in
auto)
## From git-log(1):
## %G?: show "G" for a Good signature, "B" for a Bad signature, "U"
## for a good, untrusted signature and "N" for no signature
if ! GNUPGHOME=$AUTHORIZED_SIGNERS_DIR git log --format='%G?' -1 | egrep -q '^(G|U)$'
then
echo "Commit tree tip not signed by an authorized signer. Terminating build."
exit 1
fi
;;
force)
true
;;
*)
echo "$0 <auto|force>"
echo
echo "auto: only builds if the latest commit is GPG signed by an authorized key"
echo "force: builds latest commit no matter what"
exit 1
;;
esac
# Copy files to temporary directory
rsync -rt --delete "$SITEDIR/" "$WORKDIR/"
# Get last modification time for _buildlock
touch "$SITEDIR/_buildlock"
lasttime=`stat -c %Y "$SITEDIR/_buildlock" | cut -d ' ' -f1`
# Build website in a child process
(
source /etc/profile.d/rvm.sh
cd $WORKDIR
make deployment && touch "$WORKDIR/_builddone" || touch "$WORKDIR/_buildfail"
)&
# Loop every 1 second to check status
while true
do
# Exit if site has been failed to build
if [ -e "$WORKDIR/_buildfail" ]; then
echo "Build failed"
exit
fi
# Update site and exit if site has been successfully built
if [ -e "$WORKDIR/_builddone" ]; then
find $WORKDIR/_site \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' -o -iname '*.rss' -o -iname '*.xml' -o -iname '*.svg' -o -iname '*.ttf' \) -exec gzip -9 -k {} \;
rsync --delete -zrt $WORKDIR/_site/ $DESTDIR/
echo "Upload done; terminating script"
exit
fi
# Cancel script if a concurrent script has touched _buildlock
if [ -e "$SITEDIR/_buildlock" ]; then
time=`stat -c %Y "$SITEDIR/_buildlock" | cut -d ' ' -f1`
if [ $time != $lasttime ]; then
echo "Build cancelled"
exit
fi
fi
sleep 1
done
| {
"pile_set_name": "Github"
} |
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component> | {
"pile_set_name": "Github"
} |
package configs
// Network defines configuration for a container's networking stack
//
// The network configuration can be omitted from a container causing the
// container to be setup with the host's networking stack
type Network struct {
// Type sets the networks type, commonly veth and loopback
Type string `json:"type"`
// Name of the network interface
Name string `json:"name"`
// The bridge to use.
Bridge string `json:"bridge"`
// MacAddress contains the MAC address to set on the network interface
MacAddress string `json:"mac_address"`
// Address contains the IPv4 and mask to set on the network interface
Address string `json:"address"`
// Gateway sets the gateway address that is used as the default for the interface
Gateway string `json:"gateway"`
// IPv6Address contains the IPv6 and mask to set on the network interface
IPv6Address string `json:"ipv6_address"`
// IPv6Gateway sets the ipv6 gateway address that is used as the default for the interface
IPv6Gateway string `json:"ipv6_gateway"`
// Mtu sets the mtu value for the interface and will be mirrored on both the host and
// container's interfaces if a pair is created, specifically in the case of type veth
// Note: This does not apply to loopback interfaces.
Mtu int `json:"mtu"`
// TxQueueLen sets the tx_queuelen value for the interface and will be mirrored on both the host and
// container's interfaces if a pair is created, specifically in the case of type veth
// Note: This does not apply to loopback interfaces.
TxQueueLen int `json:"txqueuelen"`
// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
// container.
HostInterfaceName string `json:"host_interface_name"`
// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
// bridge port in the case of type veth
// Note: This is unsupported on some systems.
// Note: This does not apply to loopback interfaces.
HairpinMode bool `json:"hairpin_mode"`
}
// Routes can be specified to create entries in the route table as the container is started
//
// All of destination, source, and gateway should be either IPv4 or IPv6.
// One of the three options must be present, and omitted entries will use their
// IP family default for the route table. For IPv4 for example, setting the
// gateway to 1.2.3.4 and the interface to eth0 will set up a standard
// destination of 0.0.0.0(or *) when viewed in the route table.
type Route struct {
// Sets the destination and mask, should be a CIDR. Accepts IPv4 and IPv6
Destination string `json:"destination"`
// Sets the source and mask, should be a CIDR. Accepts IPv4 and IPv6
Source string `json:"source"`
// Sets the gateway. Accepts IPv4 and IPv6
Gateway string `json:"gateway"`
// The device to set this route up for, for example: eth0
InterfaceName string `json:"interface_name"`
}
| {
"pile_set_name": "Github"
} |
//
// VROConstraint.h
// ViroRenderer
//
// Created by Raj Advani on 3/9/16.
// Copyright © 2016 Viro Media. All rights reserved.
//
// 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, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef VROConstraint_h
#define VROConstraint_h
#include <stdio.h>
#include <memory>
class VRONode;
class VROMatrix4f;
class VROQuaternion;
class VROVector3f;
class VRORenderContext;
enum class VROConstraintType {
Billboard,
Bone
};
class VROConstraint {
public:
virtual VROMatrix4f getTransform(const VRORenderContext &context,
VROMatrix4f transform) = 0;
virtual VROConstraintType getConstraintType() {
return VROConstraintType::Billboard;
}
};
#endif /* VROConstraint_h */
| {
"pile_set_name": "Github"
} |
package org.apache.spark.ml.dsl
/**
* Created by peng on 29/04/16.
*/
sealed abstract class SchemaAdaptation
object SchemaAdaptations {
//disable schema validations ( e.g. Transformer.transformSchema)
sealed trait TypeUnsafe extends SchemaAdaptation
sealed trait FailOnInconsistentSchema extends SchemaAdaptation
sealed trait FailOnNonExistingInputCol extends SchemaAdaptation
object FailFast extends FailOnInconsistentSchema with FailOnNonExistingInputCol
object FailFast_TypeUnsafe extends FailOnNonExistingInputCol with TypeUnsafe
//allow incomplete output
sealed abstract class IgnoreIrrelevant extends SchemaAdaptation
object IgnoreIrrelevant extends IgnoreIrrelevant
object IgnoreIrrelevant_TypeUnsafe extends IgnoreIrrelevant with TypeUnsafe
object IgnoreIrrelevant_ValidateSchema extends IgnoreIrrelevant with FailOnInconsistentSchema
object Force extends TypeUnsafe
}
| {
"pile_set_name": "Github"
} |
/* crypto/ripemd/rmd_locl.h */
/* Copyright (C) 1995-1998 Eric Young ([email protected])
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson ([email protected]).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young ([email protected])"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson ([email protected])"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include <stdlib.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/ripemd.h>
#ifndef RIPEMD160_LONG_LOG2
# define RIPEMD160_LONG_LOG2 2 /* default to 32 bits */
#endif
/*
* DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c
* FOR EXPLANATIONS ON FOLLOWING "CODE."
* <[email protected]>
*/
#ifdef RMD160_ASM
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
# define ripemd160_block_data_order ripemd160_block_asm_data_order
# endif
#endif
void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num);
#define DATA_ORDER_IS_LITTLE_ENDIAN
#define HASH_LONG RIPEMD160_LONG
#define HASH_CTX RIPEMD160_CTX
#define HASH_CBLOCK RIPEMD160_CBLOCK
#define HASH_UPDATE RIPEMD160_Update
#define HASH_TRANSFORM RIPEMD160_Transform
#define HASH_FINAL RIPEMD160_Final
#define HASH_MAKE_STRING(c,s) do { \
unsigned long ll; \
ll=(c)->A; (void)HOST_l2c(ll,(s)); \
ll=(c)->B; (void)HOST_l2c(ll,(s)); \
ll=(c)->C; (void)HOST_l2c(ll,(s)); \
ll=(c)->D; (void)HOST_l2c(ll,(s)); \
ll=(c)->E; (void)HOST_l2c(ll,(s)); \
} while (0)
#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
#include "md32_common.h"
#if 0
# define F1(x,y,z) ((x)^(y)^(z))
# define F2(x,y,z) (((x)&(y))|((~x)&z))
# define F3(x,y,z) (((x)|(~y))^(z))
# define F4(x,y,z) (((x)&(z))|((y)&(~(z))))
# define F5(x,y,z) ((x)^((y)|(~(z))))
#else
/*
* Transformed F2 and F4 are courtesy of Wei Dai <[email protected]>
*/
# define F1(x,y,z) ((x) ^ (y) ^ (z))
# define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z))
# define F3(x,y,z) (((~(y)) | (x)) ^ (z))
# define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y))
# define F5(x,y,z) (((~(z)) | (y)) ^ (x))
#endif
#define RIPEMD160_A 0x67452301L
#define RIPEMD160_B 0xEFCDAB89L
#define RIPEMD160_C 0x98BADCFEL
#define RIPEMD160_D 0x10325476L
#define RIPEMD160_E 0xC3D2E1F0L
#include "rmdconst.h"
#define RIP1(a,b,c,d,e,w,s) { \
a+=F1(b,c,d)+X(w); \
a=ROTATE(a,s)+e; \
c=ROTATE(c,10); }
#define RIP2(a,b,c,d,e,w,s,K) { \
a+=F2(b,c,d)+X(w)+K; \
a=ROTATE(a,s)+e; \
c=ROTATE(c,10); }
#define RIP3(a,b,c,d,e,w,s,K) { \
a+=F3(b,c,d)+X(w)+K; \
a=ROTATE(a,s)+e; \
c=ROTATE(c,10); }
#define RIP4(a,b,c,d,e,w,s,K) { \
a+=F4(b,c,d)+X(w)+K; \
a=ROTATE(a,s)+e; \
c=ROTATE(c,10); }
#define RIP5(a,b,c,d,e,w,s,K) { \
a+=F5(b,c,d)+X(w)+K; \
a=ROTATE(a,s)+e; \
c=ROTATE(c,10); }
| {
"pile_set_name": "Github"
} |
/*
* A Plugin that integrates the AMD AMF encoder into OBS Studio
* Copyright (C) 2016 - 2018 Michael Fabian Dirks
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "amf-capabilities.hpp"
#include "utility.hpp"
using namespace Plugin;
using namespace Plugin::AMD;
#pragma region Singleton
static CapabilityManager* __instance;
static std::mutex __instance_mutex;
void Plugin::AMD::CapabilityManager::Initialize()
{
const std::lock_guard<std::mutex> lock(__instance_mutex);
if (!__instance)
__instance = new CapabilityManager();
}
CapabilityManager* Plugin::AMD::CapabilityManager::Instance()
{
const std::lock_guard<std::mutex> lock(__instance_mutex);
return __instance;
}
void Plugin::AMD::CapabilityManager::Finalize()
{
const std::lock_guard<std::mutex> lock(__instance_mutex);
if (__instance)
delete __instance;
__instance = nullptr;
}
#pragma endregion Singleton
Plugin::AMD::CapabilityManager::CapabilityManager()
{
// Potential fix for unintended crashes by AMD including asserts in release builds.
AMD::AMF::Instance()->EnableDebugTrace(false);
// Key order: API, Adapter, Codec
for (auto api : API::EnumerateAPIs()) {
PLOG_DEBUG("[Capability Manager] Testing %s API...", api->GetName().c_str());
for (auto adapter : api->EnumerateAdapters()) {
std::pair<Codec, bool> test_codecs[] = {
std::make_pair(Codec::AVC, false),
std::make_pair(Codec::HEVC, false),
};
for (auto& codec : test_codecs) {
try {
std::unique_ptr<AMD::Encoder> enc;
if (codec.first == Codec::AVC || codec.first == Codec::SVC) {
enc = std::make_unique<AMD::EncoderH264>(api, adapter);
} else if (codec.first == Codec::HEVC) {
enc = std::make_unique<AMD::EncoderH265>(api, adapter);
}
if (enc != nullptr) {
codec.second = true;
}
} catch (const std::exception& e) {
PLOG_DEBUG("[Capability Manager] Testing %s Adapter '%s' with codec %s failed, reason: %s",
api->GetName().c_str(), adapter.Name.c_str(), Utility::CodecToString(codec.first),
e.what());
#ifdef LITE_OBS
e;
#endif
}
std::tuple<API::Type, API::Adapter, AMD::Codec> key =
std::make_tuple(api->GetType(), adapter, codec.first);
m_CapabilityMap[key] = codec.second;
}
PLOG_INFO(
"[Capability Manager] Testing %s Adapter '%s':\n"
" %s: %s\n"
" %s: %s\n",
api->GetName().c_str(), adapter.Name.c_str(), Utility::CodecToString(test_codecs[0].first),
test_codecs[0].second ? "Supported" : "Not Supported", Utility::CodecToString(test_codecs[1].first),
test_codecs[1].second ? "Supported" : "Not Supported");
}
}
}
Plugin::AMD::CapabilityManager::~CapabilityManager() {}
bool Plugin::AMD::CapabilityManager::IsCodecSupported(AMD::Codec codec)
{
for (auto api : API::EnumerateAPIs()) {
if (IsCodecSupportedByAPI(codec, api->GetType()))
return true;
}
return false;
}
bool Plugin::AMD::CapabilityManager::IsCodecSupportedByAPI(AMD::Codec codec, API::Type type)
{
auto api = API::GetAPI(type);
for (auto adapter : api->EnumerateAdapters()) {
if (IsCodecSupportedByAPIAdapter(codec, type, adapter) == true)
return true;
}
return false;
}
bool Plugin::AMD::CapabilityManager::IsCodecSupportedByAPIAdapter(AMD::Codec codec, API::Type api, API::Adapter adapter)
{
return m_CapabilityMap[std::make_tuple(api, adapter, codec)];
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (C) International Business Machines Corp., 2000-2005
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* jfs_xtree.c: extent allocation descriptor B+-tree manager
*/
#include <linux/fs.h>
#include <linux/module.h>
#include <linux/quotaops.h>
#include <linux/seq_file.h>
#include "jfs_incore.h"
#include "jfs_filsys.h"
#include "jfs_metapage.h"
#include "jfs_dmap.h"
#include "jfs_dinode.h"
#include "jfs_superblock.h"
#include "jfs_debug.h"
/*
* xtree local flag
*/
#define XT_INSERT 0x00000001
/*
* xtree key/entry comparison: extent offset
*
* return:
* -1: k < start of extent
* 0: start_of_extent <= k <= end_of_extent
* 1: k > end_of_extent
*/
#define XT_CMP(CMP, K, X, OFFSET64)\
{\
OFFSET64 = offsetXAD(X);\
(CMP) = ((K) >= OFFSET64 + lengthXAD(X)) ? 1 :\
((K) < OFFSET64) ? -1 : 0;\
}
/* write a xad entry */
#define XT_PUTENTRY(XAD, FLAG, OFF, LEN, ADDR)\
{\
(XAD)->flag = (FLAG);\
XADoffset((XAD), (OFF));\
XADlength((XAD), (LEN));\
XADaddress((XAD), (ADDR));\
}
#define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot)
/* get page buffer for specified block address */
/* ToDo: Replace this ugly macro with a function */
#define XT_GETPAGE(IP, BN, MP, SIZE, P, RC) \
do { \
BT_GETPAGE(IP, BN, MP, xtpage_t, SIZE, P, RC, i_xtroot); \
if (!(RC)) { \
if ((le16_to_cpu((P)->header.nextindex) < XTENTRYSTART) || \
(le16_to_cpu((P)->header.nextindex) > \
le16_to_cpu((P)->header.maxentry)) || \
(le16_to_cpu((P)->header.maxentry) > \
(((BN) == 0) ? XTROOTMAXSLOT : PSIZE >> L2XTSLOTSIZE))) { \
jfs_error((IP)->i_sb, \
"XT_GETPAGE: xtree page corrupt\n"); \
BT_PUTPAGE(MP); \
MP = NULL; \
RC = -EIO; \
} \
} \
} while (0)
/* for consistency */
#define XT_PUTPAGE(MP) BT_PUTPAGE(MP)
#define XT_GETSEARCH(IP, LEAF, BN, MP, P, INDEX) \
BT_GETSEARCH(IP, LEAF, BN, MP, xtpage_t, P, INDEX, i_xtroot)
/* xtree entry parameter descriptor */
struct xtsplit {
struct metapage *mp;
s16 index;
u8 flag;
s64 off;
s64 addr;
int len;
struct pxdlist *pxdlist;
};
/*
* statistics
*/
#ifdef CONFIG_JFS_STATISTICS
static struct {
uint search;
uint fastSearch;
uint split;
} xtStat;
#endif
/*
* forward references
*/
static int xtSearch(struct inode *ip, s64 xoff, s64 *next, int *cmpp,
struct btstack * btstack, int flag);
static int xtSplitUp(tid_t tid,
struct inode *ip,
struct xtsplit * split, struct btstack * btstack);
static int xtSplitPage(tid_t tid, struct inode *ip, struct xtsplit * split,
struct metapage ** rmpp, s64 * rbnp);
static int xtSplitRoot(tid_t tid, struct inode *ip,
struct xtsplit * split, struct metapage ** rmpp);
#ifdef _STILL_TO_PORT
static int xtDeleteUp(tid_t tid, struct inode *ip, struct metapage * fmp,
xtpage_t * fp, struct btstack * btstack);
static int xtSearchNode(struct inode *ip,
xad_t * xad,
int *cmpp, struct btstack * btstack, int flag);
static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * fp);
#endif /* _STILL_TO_PORT */
/*
* xtLookup()
*
* function: map a single page into a physical extent;
*/
int xtLookup(struct inode *ip, s64 lstart,
s64 llen, int *pflag, s64 * paddr, s32 * plen, int no_check)
{
int rc = 0;
struct btstack btstack;
int cmp;
s64 bn;
struct metapage *mp;
xtpage_t *p;
int index;
xad_t *xad;
s64 next, size, xoff, xend;
int xlen;
s64 xaddr;
*paddr = 0;
*plen = llen;
if (!no_check) {
/* is lookup offset beyond eof ? */
size = ((u64) ip->i_size + (JFS_SBI(ip->i_sb)->bsize - 1)) >>
JFS_SBI(ip->i_sb)->l2bsize;
if (lstart >= size)
return 0;
}
/*
* search for the xad entry covering the logical extent
*/
//search:
if ((rc = xtSearch(ip, lstart, &next, &cmp, &btstack, 0))) {
jfs_err("xtLookup: xtSearch returned %d", rc);
return rc;
}
/*
* compute the physical extent covering logical extent
*
* N.B. search may have failed (e.g., hole in sparse file),
* and returned the index of the next entry.
*/
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
/* is xad found covering start of logical extent ?
* lstart is a page start address,
* i.e., lstart cannot start in a hole;
*/
if (cmp) {
if (next)
*plen = min(next - lstart, llen);
goto out;
}
/*
* lxd covered by xad
*/
xad = &p->xad[index];
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
xend = xoff + xlen;
xaddr = addressXAD(xad);
/* initialize new pxd */
*pflag = xad->flag;
*paddr = xaddr + (lstart - xoff);
/* a page must be fully covered by an xad */
*plen = min(xend - lstart, llen);
out:
XT_PUTPAGE(mp);
return rc;
}
/*
* xtSearch()
*
* function: search for the xad entry covering specified offset.
*
* parameters:
* ip - file object;
* xoff - extent offset;
* nextp - address of next extent (if any) for search miss
* cmpp - comparison result:
* btstack - traverse stack;
* flag - search process flag (XT_INSERT);
*
* returns:
* btstack contains (bn, index) of search path traversed to the entry.
* *cmpp is set to result of comparison with the entry returned.
* the page containing the entry is pinned at exit.
*/
static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp,
int *cmpp, struct btstack * btstack, int flag)
{
struct jfs_inode_info *jfs_ip = JFS_IP(ip);
int rc = 0;
int cmp = 1; /* init for empty page */
s64 bn; /* block number */
struct metapage *mp; /* page buffer */
xtpage_t *p; /* page */
xad_t *xad;
int base, index, lim, btindex;
struct btframe *btsp;
int nsplit = 0; /* number of pages to split */
s64 t64;
s64 next = 0;
INCREMENT(xtStat.search);
BT_CLR(btstack);
btstack->nsplit = 0;
/*
* search down tree from root:
*
* between two consecutive entries of <Ki, Pi> and <Kj, Pj> of
* internal page, child page Pi contains entry with k, Ki <= K < Kj.
*
* if entry with search key K is not found
* internal page search find the entry with largest key Ki
* less than K which point to the child page to search;
* leaf page search find the entry with smallest key Kj
* greater than K so that the returned index is the position of
* the entry to be shifted right for insertion of new entry.
* for empty tree, search key is greater than any key of the tree.
*
* by convention, root bn = 0.
*/
for (bn = 0;;) {
/* get/pin the page to search */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/* try sequential access heuristics with the previous
* access entry in target leaf page:
* once search narrowed down into the target leaf,
* key must either match an entry in the leaf or
* key entry does not exist in the tree;
*/
//fastSearch:
if ((jfs_ip->btorder & BT_SEQUENTIAL) &&
(p->header.flag & BT_LEAF) &&
(index = jfs_ip->btindex) <
le16_to_cpu(p->header.nextindex)) {
xad = &p->xad[index];
t64 = offsetXAD(xad);
if (xoff < t64 + lengthXAD(xad)) {
if (xoff >= t64) {
*cmpp = 0;
goto out;
}
/* stop sequential access heuristics */
goto binarySearch;
} else { /* (t64 + lengthXAD(xad)) <= xoff */
/* try next sequential entry */
index++;
if (index <
le16_to_cpu(p->header.nextindex)) {
xad++;
t64 = offsetXAD(xad);
if (xoff < t64 + lengthXAD(xad)) {
if (xoff >= t64) {
*cmpp = 0;
goto out;
}
/* miss: key falls between
* previous and this entry
*/
*cmpp = 1;
next = t64;
goto out;
}
/* (xoff >= t64 + lengthXAD(xad));
* matching entry may be further out:
* stop heuristic search
*/
/* stop sequential access heuristics */
goto binarySearch;
}
/* (index == p->header.nextindex);
* miss: key entry does not exist in
* the target leaf/tree
*/
*cmpp = 1;
goto out;
}
/*
* if hit, return index of the entry found, and
* if miss, where new entry with search key is
* to be inserted;
*/
out:
/* compute number of pages to split */
if (flag & XT_INSERT) {
if (p->header.nextindex == /* little-endian */
p->header.maxentry)
nsplit++;
else
nsplit = 0;
btstack->nsplit = nsplit;
}
/* save search result */
btsp = btstack->top;
btsp->bn = bn;
btsp->index = index;
btsp->mp = mp;
/* update sequential access heuristics */
jfs_ip->btindex = index;
if (nextp)
*nextp = next;
INCREMENT(xtStat.fastSearch);
return 0;
}
/* well, ... full search now */
binarySearch:
lim = le16_to_cpu(p->header.nextindex) - XTENTRYSTART;
/*
* binary search with search key K on the current page
*/
for (base = XTENTRYSTART; lim; lim >>= 1) {
index = base + (lim >> 1);
XT_CMP(cmp, xoff, &p->xad[index], t64);
if (cmp == 0) {
/*
* search hit
*/
/* search hit - leaf page:
* return the entry found
*/
if (p->header.flag & BT_LEAF) {
*cmpp = cmp;
/* compute number of pages to split */
if (flag & XT_INSERT) {
if (p->header.nextindex ==
p->header.maxentry)
nsplit++;
else
nsplit = 0;
btstack->nsplit = nsplit;
}
/* save search result */
btsp = btstack->top;
btsp->bn = bn;
btsp->index = index;
btsp->mp = mp;
/* init sequential access heuristics */
btindex = jfs_ip->btindex;
if (index == btindex ||
index == btindex + 1)
jfs_ip->btorder = BT_SEQUENTIAL;
else
jfs_ip->btorder = BT_RANDOM;
jfs_ip->btindex = index;
return 0;
}
/* search hit - internal page:
* descend/search its child page
*/
if (index < le16_to_cpu(p->header.nextindex)-1)
next = offsetXAD(&p->xad[index + 1]);
goto next;
}
if (cmp > 0) {
base = index + 1;
--lim;
}
}
/*
* search miss
*
* base is the smallest index with key (Kj) greater than
* search key (K) and may be zero or maxentry index.
*/
if (base < le16_to_cpu(p->header.nextindex))
next = offsetXAD(&p->xad[base]);
/*
* search miss - leaf page:
*
* return location of entry (base) where new entry with
* search key K is to be inserted.
*/
if (p->header.flag & BT_LEAF) {
*cmpp = cmp;
/* compute number of pages to split */
if (flag & XT_INSERT) {
if (p->header.nextindex ==
p->header.maxentry)
nsplit++;
else
nsplit = 0;
btstack->nsplit = nsplit;
}
/* save search result */
btsp = btstack->top;
btsp->bn = bn;
btsp->index = base;
btsp->mp = mp;
/* init sequential access heuristics */
btindex = jfs_ip->btindex;
if (base == btindex || base == btindex + 1)
jfs_ip->btorder = BT_SEQUENTIAL;
else
jfs_ip->btorder = BT_RANDOM;
jfs_ip->btindex = base;
if (nextp)
*nextp = next;
return 0;
}
/*
* search miss - non-leaf page:
*
* if base is non-zero, decrement base by one to get the parent
* entry of the child page to search.
*/
index = base ? base - 1 : base;
/*
* go down to child page
*/
next:
/* update number of pages to split */
if (p->header.nextindex == p->header.maxentry)
nsplit++;
else
nsplit = 0;
/* push (bn, index) of the parent page/entry */
if (BT_STACK_FULL(btstack)) {
jfs_error(ip->i_sb, "stack overrun!\n");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(btstack, bn, index);
/* get the child page block number */
bn = addressXAD(&p->xad[index]);
/* unpin the parent page */
XT_PUTPAGE(mp);
}
}
/*
* xtInsert()
*
* function:
*
* parameter:
* tid - transaction id;
* ip - file object;
* xflag - extent flag (XAD_NOTRECORDED):
* xoff - extent offset;
* xlen - extent length;
* xaddrp - extent address pointer (in/out):
* if (*xaddrp)
* caller allocated data extent at *xaddrp;
* else
* allocate data extent and return its xaddr;
* flag -
*
* return:
*/
int xtInsert(tid_t tid, /* transaction id */
struct inode *ip, int xflag, s64 xoff, s32 xlen, s64 * xaddrp,
int flag)
{
int rc = 0;
s64 xaddr, hint;
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* base B+-tree index page */
s64 bn;
int index, nextindex;
struct btstack btstack; /* traverse stack */
struct xtsplit split; /* split information */
xad_t *xad;
int cmp;
s64 next;
struct tlock *tlck;
struct xtlock *xtlck;
jfs_info("xtInsert: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
/*
* search for the entry location at which to insert:
*
* xtFastSearch() and xtSearch() both returns (leaf page
* pinned, index at which to insert).
* n.b. xtSearch() may return index of maxentry of
* the full page.
*/
if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
/* This test must follow XT_GETSEARCH since mp must be valid if
* we branch to out: */
if ((cmp == 0) || (next && (xlen > next - xoff))) {
rc = -EEXIST;
goto out;
}
/*
* allocate data extent requested
*
* allocation hint: last xad
*/
if ((xaddr = *xaddrp) == 0) {
if (index > XTENTRYSTART) {
xad = &p->xad[index - 1];
hint = addressXAD(xad) + lengthXAD(xad) - 1;
} else
hint = 0;
if ((rc = dquot_alloc_block(ip, xlen)))
goto out;
if ((rc = dbAlloc(ip, hint, (s64) xlen, &xaddr))) {
dquot_free_block(ip, xlen);
goto out;
}
}
/*
* insert entry for new extent
*/
xflag |= XAD_NEW;
/*
* if the leaf page is full, split the page and
* propagate up the router entry for the new page from split
*
* The xtSplitUp() will insert the entry and unpin the leaf page.
*/
nextindex = le16_to_cpu(p->header.nextindex);
if (nextindex == le16_to_cpu(p->header.maxentry)) {
split.mp = mp;
split.index = index;
split.flag = xflag;
split.off = xoff;
split.len = xlen;
split.addr = xaddr;
split.pxdlist = NULL;
if ((rc = xtSplitUp(tid, ip, &split, &btstack))) {
/* undo data extent allocation */
if (*xaddrp == 0) {
dbFree(ip, xaddr, (s64) xlen);
dquot_free_block(ip, xlen);
}
return rc;
}
*xaddrp = xaddr;
return 0;
}
/*
* insert the new entry into the leaf page
*/
/*
* acquire a transaction lock on the leaf page;
*
* action: xad insertion/extension;
*/
BT_MARK_DIRTY(mp, ip);
/* if insert into middle, shift right remaining entries. */
if (index < nextindex)
memmove(&p->xad[index + 1], &p->xad[index],
(nextindex - index) * sizeof(xad_t));
/* insert the new entry: mark the entry NEW */
xad = &p->xad[index];
XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);
/* advance next available entry index */
le16_add_cpu(&p->header.nextindex, 1);
/* Don't log it if there are no links to the file */
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset =
(xtlck->lwm.offset) ? min(index,
(int)xtlck->lwm.offset) : index;
xtlck->lwm.length =
le16_to_cpu(p->header.nextindex) - xtlck->lwm.offset;
}
*xaddrp = xaddr;
out:
/* unpin the leaf page */
XT_PUTPAGE(mp);
return rc;
}
/*
* xtSplitUp()
*
* function:
* split full pages as propagating insertion up the tree
*
* parameter:
* tid - transaction id;
* ip - file object;
* split - entry parameter descriptor;
* btstack - traverse stack from xtSearch()
*
* return:
*/
static int
xtSplitUp(tid_t tid,
struct inode *ip, struct xtsplit * split, struct btstack * btstack)
{
int rc = 0;
struct metapage *smp;
xtpage_t *sp; /* split page */
struct metapage *rmp;
s64 rbn; /* new right page block number */
struct metapage *rcmp;
xtpage_t *rcp; /* right child page */
s64 rcbn; /* right child page block number */
int skip; /* index of entry of insertion */
int nextindex; /* next available entry index of p */
struct btframe *parent; /* parent page entry on traverse stack */
xad_t *xad;
s64 xaddr;
int xlen;
int nsplit; /* number of pages split */
struct pxdlist pxdlist;
pxd_t *pxd;
struct tlock *tlck;
struct xtlock *xtlck;
smp = split->mp;
sp = XT_PAGE(ip, smp);
/* is inode xtree root extension/inline EA area free ? */
if ((sp->header.flag & BT_ROOT) && (!S_ISDIR(ip->i_mode)) &&
(le16_to_cpu(sp->header.maxentry) < XTROOTMAXSLOT) &&
(JFS_IP(ip)->mode2 & INLINEEA)) {
sp->header.maxentry = cpu_to_le16(XTROOTMAXSLOT);
JFS_IP(ip)->mode2 &= ~INLINEEA;
BT_MARK_DIRTY(smp, ip);
/*
* acquire a transaction lock on the leaf page;
*
* action: xad insertion/extension;
*/
/* if insert into middle, shift right remaining entries. */
skip = split->index;
nextindex = le16_to_cpu(sp->header.nextindex);
if (skip < nextindex)
memmove(&sp->xad[skip + 1], &sp->xad[skip],
(nextindex - skip) * sizeof(xad_t));
/* insert the new entry: mark the entry NEW */
xad = &sp->xad[skip];
XT_PUTENTRY(xad, split->flag, split->off, split->len,
split->addr);
/* advance next available entry index */
le16_add_cpu(&sp->header.nextindex, 1);
/* Don't log it if there are no links to the file */
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, smp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(skip, (int)xtlck->lwm.offset) : skip;
xtlck->lwm.length =
le16_to_cpu(sp->header.nextindex) -
xtlck->lwm.offset;
}
return 0;
}
/*
* allocate new index blocks to cover index page split(s)
*
* allocation hint: ?
*/
if (split->pxdlist == NULL) {
nsplit = btstack->nsplit;
split->pxdlist = &pxdlist;
pxdlist.maxnpxd = pxdlist.npxd = 0;
pxd = &pxdlist.pxd[0];
xlen = JFS_SBI(ip->i_sb)->nbperpage;
for (; nsplit > 0; nsplit--, pxd++) {
if ((rc = dbAlloc(ip, (s64) 0, (s64) xlen, &xaddr))
== 0) {
PXDaddress(pxd, xaddr);
PXDlength(pxd, xlen);
pxdlist.maxnpxd++;
continue;
}
/* undo allocation */
XT_PUTPAGE(smp);
return rc;
}
}
/*
* Split leaf page <sp> into <sp> and a new right page <rp>.
*
* The split routines insert the new entry into the leaf page,
* and acquire txLock as appropriate.
* return <rp> pinned and its block number <rpbn>.
*/
rc = (sp->header.flag & BT_ROOT) ?
xtSplitRoot(tid, ip, split, &rmp) :
xtSplitPage(tid, ip, split, &rmp, &rbn);
XT_PUTPAGE(smp);
if (rc)
return -EIO;
/*
* propagate up the router entry for the leaf page just split
*
* insert a router entry for the new page into the parent page,
* propagate the insert/split up the tree by walking back the stack
* of (bn of parent page, index of child page entry in parent page)
* that were traversed during the search for the page that split.
*
* the propagation of insert/split up the tree stops if the root
* splits or the page inserted into doesn't have to split to hold
* the new entry.
*
* the parent entry for the split page remains the same, and
* a new entry is inserted at its right with the first key and
* block number of the new right page.
*
* There are a maximum of 3 pages pinned at any time:
* right child, left parent and right parent (when the parent splits)
* to keep the child page pinned while working on the parent.
* make sure that all pins are released at exit.
*/
while ((parent = BT_POP(btstack)) != NULL) {
/* parent page specified by stack frame <parent> */
/* keep current child pages <rcp> pinned */
rcmp = rmp;
rcbn = rbn;
rcp = XT_PAGE(ip, rcmp);
/*
* insert router entry in parent for new right child page <rp>
*/
/* get/pin the parent page <sp> */
XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc);
if (rc) {
XT_PUTPAGE(rcmp);
return rc;
}
/*
* The new key entry goes ONE AFTER the index of parent entry,
* because the split was to the right.
*/
skip = parent->index + 1;
/*
* split or shift right remaining entries of the parent page
*/
nextindex = le16_to_cpu(sp->header.nextindex);
/*
* parent page is full - split the parent page
*/
if (nextindex == le16_to_cpu(sp->header.maxentry)) {
/* init for parent page split */
split->mp = smp;
split->index = skip; /* index at insert */
split->flag = XAD_NEW;
split->off = offsetXAD(&rcp->xad[XTENTRYSTART]);
split->len = JFS_SBI(ip->i_sb)->nbperpage;
split->addr = rcbn;
/* unpin previous right child page */
XT_PUTPAGE(rcmp);
/* The split routines insert the new entry,
* and acquire txLock as appropriate.
* return <rp> pinned and its block number <rpbn>.
*/
rc = (sp->header.flag & BT_ROOT) ?
xtSplitRoot(tid, ip, split, &rmp) :
xtSplitPage(tid, ip, split, &rmp, &rbn);
if (rc) {
XT_PUTPAGE(smp);
return rc;
}
XT_PUTPAGE(smp);
/* keep new child page <rp> pinned */
}
/*
* parent page is not full - insert in parent page
*/
else {
/*
* insert router entry in parent for the right child
* page from the first entry of the right child page:
*/
/*
* acquire a transaction lock on the parent page;
*
* action: router xad insertion;
*/
BT_MARK_DIRTY(smp, ip);
/*
* if insert into middle, shift right remaining entries
*/
if (skip < nextindex)
memmove(&sp->xad[skip + 1], &sp->xad[skip],
(nextindex -
skip) << L2XTSLOTSIZE);
/* insert the router entry */
xad = &sp->xad[skip];
XT_PUTENTRY(xad, XAD_NEW,
offsetXAD(&rcp->xad[XTENTRYSTART]),
JFS_SBI(ip->i_sb)->nbperpage, rcbn);
/* advance next available entry index. */
le16_add_cpu(&sp->header.nextindex, 1);
/* Don't log it if there are no links to the file */
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, smp,
tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(skip, (int)xtlck->lwm.offset) : skip;
xtlck->lwm.length =
le16_to_cpu(sp->header.nextindex) -
xtlck->lwm.offset;
}
/* unpin parent page */
XT_PUTPAGE(smp);
/* exit propagate up */
break;
}
}
/* unpin current right page */
XT_PUTPAGE(rmp);
return 0;
}
/*
* xtSplitPage()
*
* function:
* split a full non-root page into
* original/split/left page and new right page
* i.e., the original/split page remains as left page.
*
* parameter:
* int tid,
* struct inode *ip,
* struct xtsplit *split,
* struct metapage **rmpp,
* u64 *rbnp,
*
* return:
* Pointer to page in which to insert or NULL on error.
*/
static int
xtSplitPage(tid_t tid, struct inode *ip,
struct xtsplit * split, struct metapage ** rmpp, s64 * rbnp)
{
int rc = 0;
struct metapage *smp;
xtpage_t *sp;
struct metapage *rmp;
xtpage_t *rp; /* new right page allocated */
s64 rbn; /* new right page block number */
struct metapage *mp;
xtpage_t *p;
s64 nextbn;
int skip, maxentry, middle, righthalf, n;
xad_t *xad;
struct pxdlist *pxdlist;
pxd_t *pxd;
struct tlock *tlck;
struct xtlock *sxtlck = NULL, *rxtlck = NULL;
int quota_allocation = 0;
smp = split->mp;
sp = XT_PAGE(ip, smp);
INCREMENT(xtStat.split);
pxdlist = split->pxdlist;
pxd = &pxdlist->pxd[pxdlist->npxd];
pxdlist->npxd++;
rbn = addressPXD(pxd);
/* Allocate blocks to quota. */
rc = dquot_alloc_block(ip, lengthPXD(pxd));
if (rc)
goto clean_up;
quota_allocation += lengthPXD(pxd);
/*
* allocate the new right page for the split
*/
rmp = get_metapage(ip, rbn, PSIZE, 1);
if (rmp == NULL) {
rc = -EIO;
goto clean_up;
}
jfs_info("xtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
BT_MARK_DIRTY(rmp, ip);
/*
* action: new page;
*/
rp = (xtpage_t *) rmp->data;
rp->header.self = *pxd;
rp->header.flag = sp->header.flag & BT_TYPE;
rp->header.maxentry = sp->header.maxentry; /* little-endian */
rp->header.nextindex = cpu_to_le16(XTENTRYSTART);
BT_MARK_DIRTY(smp, ip);
/* Don't log it if there are no links to the file */
if (!test_cflag(COMMIT_Nolink, ip)) {
/*
* acquire a transaction lock on the new right page;
*/
tlck = txLock(tid, ip, rmp, tlckXTREE | tlckNEW);
rxtlck = (struct xtlock *) & tlck->lock;
rxtlck->lwm.offset = XTENTRYSTART;
/*
* acquire a transaction lock on the split page
*/
tlck = txLock(tid, ip, smp, tlckXTREE | tlckGROW);
sxtlck = (struct xtlock *) & tlck->lock;
}
/*
* initialize/update sibling pointers of <sp> and <rp>
*/
nextbn = le64_to_cpu(sp->header.next);
rp->header.next = cpu_to_le64(nextbn);
rp->header.prev = cpu_to_le64(addressPXD(&sp->header.self));
sp->header.next = cpu_to_le64(rbn);
skip = split->index;
/*
* sequential append at tail (after last entry of last page)
*
* if splitting the last page on a level because of appending
* a entry to it (skip is maxentry), it's likely that the access is
* sequential. adding an empty page on the side of the level is less
* work and can push the fill factor much higher than normal.
* if we're wrong it's no big deal - we will do the split the right
* way next time.
* (it may look like it's equally easy to do a similar hack for
* reverse sorted data, that is, split the tree left, but it's not.
* Be my guest.)
*/
if (nextbn == 0 && skip == le16_to_cpu(sp->header.maxentry)) {
/*
* acquire a transaction lock on the new/right page;
*
* action: xad insertion;
*/
/* insert entry at the first entry of the new right page */
xad = &rp->xad[XTENTRYSTART];
XT_PUTENTRY(xad, split->flag, split->off, split->len,
split->addr);
rp->header.nextindex = cpu_to_le16(XTENTRYSTART + 1);
if (!test_cflag(COMMIT_Nolink, ip)) {
/* rxtlck->lwm.offset = XTENTRYSTART; */
rxtlck->lwm.length = 1;
}
*rmpp = rmp;
*rbnp = rbn;
jfs_info("xtSplitPage: sp:0x%p rp:0x%p", sp, rp);
return 0;
}
/*
* non-sequential insert (at possibly middle page)
*/
/*
* update previous pointer of old next/right page of <sp>
*/
if (nextbn != 0) {
XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc);
if (rc) {
XT_PUTPAGE(rmp);
goto clean_up;
}
BT_MARK_DIRTY(mp, ip);
/*
* acquire a transaction lock on the next page;
*
* action:sibling pointer update;
*/
if (!test_cflag(COMMIT_Nolink, ip))
tlck = txLock(tid, ip, mp, tlckXTREE | tlckRELINK);
p->header.prev = cpu_to_le64(rbn);
/* sibling page may have been updated previously, or
* it may be updated later;
*/
XT_PUTPAGE(mp);
}
/*
* split the data between the split and new/right pages
*/
maxentry = le16_to_cpu(sp->header.maxentry);
middle = maxentry >> 1;
righthalf = maxentry - middle;
/*
* skip index in old split/left page - insert into left page:
*/
if (skip <= middle) {
/* move right half of split page to the new right page */
memmove(&rp->xad[XTENTRYSTART], &sp->xad[middle],
righthalf << L2XTSLOTSIZE);
/* shift right tail of left half to make room for new entry */
if (skip < middle)
memmove(&sp->xad[skip + 1], &sp->xad[skip],
(middle - skip) << L2XTSLOTSIZE);
/* insert new entry */
xad = &sp->xad[skip];
XT_PUTENTRY(xad, split->flag, split->off, split->len,
split->addr);
/* update page header */
sp->header.nextindex = cpu_to_le16(middle + 1);
if (!test_cflag(COMMIT_Nolink, ip)) {
sxtlck->lwm.offset = (sxtlck->lwm.offset) ?
min(skip, (int)sxtlck->lwm.offset) : skip;
}
rp->header.nextindex =
cpu_to_le16(XTENTRYSTART + righthalf);
}
/*
* skip index in new right page - insert into right page:
*/
else {
/* move left head of right half to right page */
n = skip - middle;
memmove(&rp->xad[XTENTRYSTART], &sp->xad[middle],
n << L2XTSLOTSIZE);
/* insert new entry */
n += XTENTRYSTART;
xad = &rp->xad[n];
XT_PUTENTRY(xad, split->flag, split->off, split->len,
split->addr);
/* move right tail of right half to right page */
if (skip < maxentry)
memmove(&rp->xad[n + 1], &sp->xad[skip],
(maxentry - skip) << L2XTSLOTSIZE);
/* update page header */
sp->header.nextindex = cpu_to_le16(middle);
if (!test_cflag(COMMIT_Nolink, ip)) {
sxtlck->lwm.offset = (sxtlck->lwm.offset) ?
min(middle, (int)sxtlck->lwm.offset) : middle;
}
rp->header.nextindex = cpu_to_le16(XTENTRYSTART +
righthalf + 1);
}
if (!test_cflag(COMMIT_Nolink, ip)) {
sxtlck->lwm.length = le16_to_cpu(sp->header.nextindex) -
sxtlck->lwm.offset;
/* rxtlck->lwm.offset = XTENTRYSTART; */
rxtlck->lwm.length = le16_to_cpu(rp->header.nextindex) -
XTENTRYSTART;
}
*rmpp = rmp;
*rbnp = rbn;
jfs_info("xtSplitPage: sp:0x%p rp:0x%p", sp, rp);
return rc;
clean_up:
/* Rollback quota allocation. */
if (quota_allocation)
dquot_free_block(ip, quota_allocation);
return (rc);
}
/*
* xtSplitRoot()
*
* function:
* split the full root page into original/root/split page and new
* right page
* i.e., root remains fixed in tree anchor (inode) and the root is
* copied to a single new right child page since root page <<
* non-root page, and the split root page contains a single entry
* for the new right child page.
*
* parameter:
* int tid,
* struct inode *ip,
* struct xtsplit *split,
* struct metapage **rmpp)
*
* return:
* Pointer to page in which to insert or NULL on error.
*/
static int
xtSplitRoot(tid_t tid,
struct inode *ip, struct xtsplit * split, struct metapage ** rmpp)
{
xtpage_t *sp;
struct metapage *rmp;
xtpage_t *rp;
s64 rbn;
int skip, nextindex;
xad_t *xad;
pxd_t *pxd;
struct pxdlist *pxdlist;
struct tlock *tlck;
struct xtlock *xtlck;
int rc;
sp = &JFS_IP(ip)->i_xtroot;
INCREMENT(xtStat.split);
/*
* allocate a single (right) child page
*/
pxdlist = split->pxdlist;
pxd = &pxdlist->pxd[pxdlist->npxd];
pxdlist->npxd++;
rbn = addressPXD(pxd);
rmp = get_metapage(ip, rbn, PSIZE, 1);
if (rmp == NULL)
return -EIO;
/* Allocate blocks to quota. */
rc = dquot_alloc_block(ip, lengthPXD(pxd));
if (rc) {
release_metapage(rmp);
return rc;
}
jfs_info("xtSplitRoot: ip:0x%p rmp:0x%p", ip, rmp);
/*
* acquire a transaction lock on the new right page;
*
* action: new page;
*/
BT_MARK_DIRTY(rmp, ip);
rp = (xtpage_t *) rmp->data;
rp->header.flag =
(sp->header.flag & BT_LEAF) ? BT_LEAF : BT_INTERNAL;
rp->header.self = *pxd;
rp->header.nextindex = cpu_to_le16(XTENTRYSTART);
rp->header.maxentry = cpu_to_le16(PSIZE >> L2XTSLOTSIZE);
/* initialize sibling pointers */
rp->header.next = 0;
rp->header.prev = 0;
/*
* copy the in-line root page into new right page extent
*/
nextindex = le16_to_cpu(sp->header.maxentry);
memmove(&rp->xad[XTENTRYSTART], &sp->xad[XTENTRYSTART],
(nextindex - XTENTRYSTART) << L2XTSLOTSIZE);
/*
* insert the new entry into the new right/child page
* (skip index in the new right page will not change)
*/
skip = split->index;
/* if insert into middle, shift right remaining entries */
if (skip != nextindex)
memmove(&rp->xad[skip + 1], &rp->xad[skip],
(nextindex - skip) * sizeof(xad_t));
xad = &rp->xad[skip];
XT_PUTENTRY(xad, split->flag, split->off, split->len, split->addr);
/* update page header */
rp->header.nextindex = cpu_to_le16(nextindex + 1);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, rmp, tlckXTREE | tlckNEW);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset = XTENTRYSTART;
xtlck->lwm.length = le16_to_cpu(rp->header.nextindex) -
XTENTRYSTART;
}
/*
* reset the root
*
* init root with the single entry for the new right page
* set the 1st entry offset to 0, which force the left-most key
* at any level of the tree to be less than any search key.
*/
/*
* acquire a transaction lock on the root page (in-memory inode);
*
* action: root split;
*/
BT_MARK_DIRTY(split->mp, ip);
xad = &sp->xad[XTENTRYSTART];
XT_PUTENTRY(xad, XAD_NEW, 0, JFS_SBI(ip->i_sb)->nbperpage, rbn);
/* update page header of root */
sp->header.flag &= ~BT_LEAF;
sp->header.flag |= BT_INTERNAL;
sp->header.nextindex = cpu_to_le16(XTENTRYSTART + 1);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, split->mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset = XTENTRYSTART;
xtlck->lwm.length = 1;
}
*rmpp = rmp;
jfs_info("xtSplitRoot: sp:0x%p rp:0x%p", sp, rp);
return 0;
}
/*
* xtExtend()
*
* function: extend in-place;
*
* note: existing extent may or may not have been committed.
* caller is responsible for pager buffer cache update, and
* working block allocation map update;
* update pmap: alloc whole extended extent;
*/
int xtExtend(tid_t tid, /* transaction id */
struct inode *ip, s64 xoff, /* delta extent offset */
s32 xlen, /* delta extent length */
int flag)
{
int rc = 0;
int cmp;
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* base B+-tree index page */
s64 bn;
int index, nextindex, len;
struct btstack btstack; /* traverse stack */
struct xtsplit split; /* split information */
xad_t *xad;
s64 xaddr;
struct tlock *tlck;
struct xtlock *xtlck = NULL;
jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen);
/* there must exist extent to be extended */
if ((rc = xtSearch(ip, xoff - 1, NULL, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
if (cmp != 0) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "xtSearch did not find extent\n");
return -EIO;
}
/* extension must be contiguous */
xad = &p->xad[index];
if ((offsetXAD(xad) + lengthXAD(xad)) != xoff) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "extension is not contiguous\n");
return -EIO;
}
/*
* acquire a transaction lock on the leaf page;
*
* action: xad insertion/extension;
*/
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
/* extend will overflow extent ? */
xlen = lengthXAD(xad) + xlen;
if ((len = xlen - MAXXLEN) <= 0)
goto extendOld;
/*
* extent overflow: insert entry for new extent
*/
//insertNew:
xoff = offsetXAD(xad) + MAXXLEN;
xaddr = addressXAD(xad) + MAXXLEN;
nextindex = le16_to_cpu(p->header.nextindex);
/*
* if the leaf page is full, insert the new entry and
* propagate up the router entry for the new page from split
*
* The xtSplitUp() will insert the entry and unpin the leaf page.
*/
if (nextindex == le16_to_cpu(p->header.maxentry)) {
/* xtSpliUp() unpins leaf pages */
split.mp = mp;
split.index = index + 1;
split.flag = XAD_NEW;
split.off = xoff; /* split offset */
split.len = len;
split.addr = xaddr;
split.pxdlist = NULL;
if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
return rc;
/* get back old page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* if leaf root has been split, original root has been
* copied to new child page, i.e., original entry now
* resides on the new child page;
*/
if (p->header.flag & BT_INTERNAL) {
ASSERT(p->header.nextindex ==
cpu_to_le16(XTENTRYSTART + 1));
xad = &p->xad[XTENTRYSTART];
bn = addressXAD(xad);
XT_PUTPAGE(mp);
/* get new child page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
}
}
/*
* insert the new entry into the leaf page
*/
else {
/* insert the new entry: mark the entry NEW */
xad = &p->xad[index + 1];
XT_PUTENTRY(xad, XAD_NEW, xoff, len, xaddr);
/* advance next available entry index */
le16_add_cpu(&p->header.nextindex, 1);
}
/* get back old entry */
xad = &p->xad[index];
xlen = MAXXLEN;
/*
* extend old extent
*/
extendOld:
XADlength(xad, xlen);
if (!(xad->flag & XAD_NEW))
xad->flag |= XAD_EXTENDED;
if (!test_cflag(COMMIT_Nolink, ip)) {
xtlck->lwm.offset =
(xtlck->lwm.offset) ? min(index,
(int)xtlck->lwm.offset) : index;
xtlck->lwm.length =
le16_to_cpu(p->header.nextindex) - xtlck->lwm.offset;
}
/* unpin the leaf page */
XT_PUTPAGE(mp);
return rc;
}
#ifdef _NOTYET
/*
* xtTailgate()
*
* function: split existing 'tail' extent
* (split offset >= start offset of tail extent), and
* relocate and extend the split tail half;
*
* note: existing extent may or may not have been committed.
* caller is responsible for pager buffer cache update, and
* working block allocation map update;
* update pmap: free old split tail extent, alloc new extent;
*/
int xtTailgate(tid_t tid, /* transaction id */
struct inode *ip, s64 xoff, /* split/new extent offset */
s32 xlen, /* new extent length */
s64 xaddr, /* new extent address */
int flag)
{
int rc = 0;
int cmp;
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* base B+-tree index page */
s64 bn;
int index, nextindex, llen, rlen;
struct btstack btstack; /* traverse stack */
struct xtsplit split; /* split information */
xad_t *xad;
struct tlock *tlck;
struct xtlock *xtlck = 0;
struct tlock *mtlck;
struct maplock *pxdlock;
/*
printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n",
(ulong)xoff, xlen, (ulong)xaddr);
*/
/* there must exist extent to be tailgated */
if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
if (cmp != 0) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "couldn't find extent\n");
return -EIO;
}
/* entry found must be last entry */
nextindex = le16_to_cpu(p->header.nextindex);
if (index != nextindex - 1) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "the entry found is not the last entry\n");
return -EIO;
}
BT_MARK_DIRTY(mp, ip);
/*
* acquire tlock of the leaf page containing original entry
*/
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
/* completely replace extent ? */
xad = &p->xad[index];
/*
printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n",
(ulong)offsetXAD(xad), lengthXAD(xad), (ulong)addressXAD(xad));
*/
if ((llen = xoff - offsetXAD(xad)) == 0)
goto updateOld;
/*
* partially replace extent: insert entry for new extent
*/
//insertNew:
/*
* if the leaf page is full, insert the new entry and
* propagate up the router entry for the new page from split
*
* The xtSplitUp() will insert the entry and unpin the leaf page.
*/
if (nextindex == le16_to_cpu(p->header.maxentry)) {
/* xtSpliUp() unpins leaf pages */
split.mp = mp;
split.index = index + 1;
split.flag = XAD_NEW;
split.off = xoff; /* split offset */
split.len = xlen;
split.addr = xaddr;
split.pxdlist = NULL;
if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
return rc;
/* get back old page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* if leaf root has been split, original root has been
* copied to new child page, i.e., original entry now
* resides on the new child page;
*/
if (p->header.flag & BT_INTERNAL) {
ASSERT(p->header.nextindex ==
cpu_to_le16(XTENTRYSTART + 1));
xad = &p->xad[XTENTRYSTART];
bn = addressXAD(xad);
XT_PUTPAGE(mp);
/* get new child page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
}
}
/*
* insert the new entry into the leaf page
*/
else {
/* insert the new entry: mark the entry NEW */
xad = &p->xad[index + 1];
XT_PUTENTRY(xad, XAD_NEW, xoff, xlen, xaddr);
/* advance next available entry index */
le16_add_cpu(&p->header.nextindex, 1);
}
/* get back old XAD */
xad = &p->xad[index];
/*
* truncate/relocate old extent at split offset
*/
updateOld:
/* update dmap for old/committed/truncated extent */
rlen = lengthXAD(xad) - llen;
if (!(xad->flag & XAD_NEW)) {
/* free from PWMAP at commit */
if (!test_cflag(COMMIT_Nolink, ip)) {
mtlck = txMaplock(tid, ip, tlckMAP);
pxdlock = (struct maplock *) & mtlck->lock;
pxdlock->flag = mlckFREEPXD;
PXDaddress(&pxdlock->pxd, addressXAD(xad) + llen);
PXDlength(&pxdlock->pxd, rlen);
pxdlock->index = 1;
}
} else
/* free from WMAP */
dbFree(ip, addressXAD(xad) + llen, (s64) rlen);
if (llen)
/* truncate */
XADlength(xad, llen);
else
/* replace */
XT_PUTENTRY(xad, XAD_NEW, xoff, xlen, xaddr);
if (!test_cflag(COMMIT_Nolink, ip)) {
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(index, (int)xtlck->lwm.offset) : index;
xtlck->lwm.length = le16_to_cpu(p->header.nextindex) -
xtlck->lwm.offset;
}
/* unpin the leaf page */
XT_PUTPAGE(mp);
return rc;
}
#endif /* _NOTYET */
/*
* xtUpdate()
*
* function: update XAD;
*
* update extent for allocated_but_not_recorded or
* compressed extent;
*
* parameter:
* nxad - new XAD;
* logical extent of the specified XAD must be completely
* contained by an existing XAD;
*/
int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad)
{ /* new XAD */
int rc = 0;
int cmp;
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* base B+-tree index page */
s64 bn;
int index0, index, newindex, nextindex;
struct btstack btstack; /* traverse stack */
struct xtsplit split; /* split information */
xad_t *xad, *lxad, *rxad;
int xflag;
s64 nxoff, xoff;
int nxlen, xlen, lxlen, rxlen;
s64 nxaddr, xaddr;
struct tlock *tlck;
struct xtlock *xtlck = NULL;
int newpage = 0;
/* there must exist extent to be tailgated */
nxoff = offsetXAD(nxad);
nxlen = lengthXAD(nxad);
nxaddr = addressXAD(nxad);
if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index0);
if (cmp != 0) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "Could not find extent\n");
return -EIO;
}
BT_MARK_DIRTY(mp, ip);
/*
* acquire tlock of the leaf page containing original entry
*/
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
xad = &p->xad[index0];
xflag = xad->flag;
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
xaddr = addressXAD(xad);
/* nXAD must be completely contained within XAD */
if ((xoff > nxoff) ||
(nxoff + nxlen > xoff + xlen)) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb,
"nXAD in not completely contained within XAD\n");
return -EIO;
}
index = index0;
newindex = index + 1;
nextindex = le16_to_cpu(p->header.nextindex);
#ifdef _JFS_WIP_NOCOALESCE
if (xoff < nxoff)
goto updateRight;
/*
* replace XAD with nXAD
*/
replace: /* (nxoff == xoff) */
if (nxlen == xlen) {
/* replace XAD with nXAD:recorded */
*xad = *nxad;
xad->flag = xflag & ~XAD_NOTRECORDED;
goto out;
} else /* (nxlen < xlen) */
goto updateLeft;
#endif /* _JFS_WIP_NOCOALESCE */
/* #ifdef _JFS_WIP_COALESCE */
if (xoff < nxoff)
goto coalesceRight;
/*
* coalesce with left XAD
*/
//coalesceLeft: /* (xoff == nxoff) */
/* is XAD first entry of page ? */
if (index == XTENTRYSTART)
goto replace;
/* is nXAD logically and physically contiguous with lXAD ? */
lxad = &p->xad[index - 1];
lxlen = lengthXAD(lxad);
if (!(lxad->flag & XAD_NOTRECORDED) &&
(nxoff == offsetXAD(lxad) + lxlen) &&
(nxaddr == addressXAD(lxad) + lxlen) &&
(lxlen + nxlen < MAXXLEN)) {
/* extend right lXAD */
index0 = index - 1;
XADlength(lxad, lxlen + nxlen);
/* If we just merged two extents together, need to make sure the
* right extent gets logged. If the left one is marked XAD_NEW,
* then we know it will be logged. Otherwise, mark as
* XAD_EXTENDED
*/
if (!(lxad->flag & XAD_NEW))
lxad->flag |= XAD_EXTENDED;
if (xlen > nxlen) {
/* truncate XAD */
XADoffset(xad, xoff + nxlen);
XADlength(xad, xlen - nxlen);
XADaddress(xad, xaddr + nxlen);
goto out;
} else { /* (xlen == nxlen) */
/* remove XAD */
if (index < nextindex - 1)
memmove(&p->xad[index], &p->xad[index + 1],
(nextindex - index -
1) << L2XTSLOTSIZE);
p->header.nextindex =
cpu_to_le16(le16_to_cpu(p->header.nextindex) -
1);
index = index0;
newindex = index + 1;
nextindex = le16_to_cpu(p->header.nextindex);
xoff = nxoff = offsetXAD(lxad);
xlen = nxlen = lxlen + nxlen;
xaddr = nxaddr = addressXAD(lxad);
goto coalesceRight;
}
}
/*
* replace XAD with nXAD
*/
replace: /* (nxoff == xoff) */
if (nxlen == xlen) {
/* replace XAD with nXAD:recorded */
*xad = *nxad;
xad->flag = xflag & ~XAD_NOTRECORDED;
goto coalesceRight;
} else /* (nxlen < xlen) */
goto updateLeft;
/*
* coalesce with right XAD
*/
coalesceRight: /* (xoff <= nxoff) */
/* is XAD last entry of page ? */
if (newindex == nextindex) {
if (xoff == nxoff)
goto out;
goto updateRight;
}
/* is nXAD logically and physically contiguous with rXAD ? */
rxad = &p->xad[index + 1];
rxlen = lengthXAD(rxad);
if (!(rxad->flag & XAD_NOTRECORDED) &&
(nxoff + nxlen == offsetXAD(rxad)) &&
(nxaddr + nxlen == addressXAD(rxad)) &&
(rxlen + nxlen < MAXXLEN)) {
/* extend left rXAD */
XADoffset(rxad, nxoff);
XADlength(rxad, rxlen + nxlen);
XADaddress(rxad, nxaddr);
/* If we just merged two extents together, need to make sure
* the left extent gets logged. If the right one is marked
* XAD_NEW, then we know it will be logged. Otherwise, mark as
* XAD_EXTENDED
*/
if (!(rxad->flag & XAD_NEW))
rxad->flag |= XAD_EXTENDED;
if (xlen > nxlen)
/* truncate XAD */
XADlength(xad, xlen - nxlen);
else { /* (xlen == nxlen) */
/* remove XAD */
memmove(&p->xad[index], &p->xad[index + 1],
(nextindex - index - 1) << L2XTSLOTSIZE);
p->header.nextindex =
cpu_to_le16(le16_to_cpu(p->header.nextindex) -
1);
}
goto out;
} else if (xoff == nxoff)
goto out;
if (xoff >= nxoff) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "xoff >= nxoff\n");
return -EIO;
}
/* #endif _JFS_WIP_COALESCE */
/*
* split XAD into (lXAD, nXAD):
*
* |---nXAD--->
* --|----------XAD----------|--
* |-lXAD-|
*/
updateRight: /* (xoff < nxoff) */
/* truncate old XAD as lXAD:not_recorded */
xad = &p->xad[index];
XADlength(xad, nxoff - xoff);
/* insert nXAD:recorded */
if (nextindex == le16_to_cpu(p->header.maxentry)) {
/* xtSpliUp() unpins leaf pages */
split.mp = mp;
split.index = newindex;
split.flag = xflag & ~XAD_NOTRECORDED;
split.off = nxoff;
split.len = nxlen;
split.addr = nxaddr;
split.pxdlist = NULL;
if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
return rc;
/* get back old page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* if leaf root has been split, original root has been
* copied to new child page, i.e., original entry now
* resides on the new child page;
*/
if (p->header.flag & BT_INTERNAL) {
ASSERT(p->header.nextindex ==
cpu_to_le16(XTENTRYSTART + 1));
xad = &p->xad[XTENTRYSTART];
bn = addressXAD(xad);
XT_PUTPAGE(mp);
/* get new child page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
} else {
/* is nXAD on new page ? */
if (newindex >
(le16_to_cpu(p->header.maxentry) >> 1)) {
newindex =
newindex -
le16_to_cpu(p->header.nextindex) +
XTENTRYSTART;
newpage = 1;
}
}
} else {
/* if insert into middle, shift right remaining entries */
if (newindex < nextindex)
memmove(&p->xad[newindex + 1], &p->xad[newindex],
(nextindex - newindex) << L2XTSLOTSIZE);
/* insert the entry */
xad = &p->xad[newindex];
*xad = *nxad;
xad->flag = xflag & ~XAD_NOTRECORDED;
/* advance next available entry index. */
p->header.nextindex =
cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
}
/*
* does nXAD force 3-way split ?
*
* |---nXAD--->|
* --|----------XAD-------------|--
* |-lXAD-| |-rXAD -|
*/
if (nxoff + nxlen == xoff + xlen)
goto out;
/* reorient nXAD as XAD for further split XAD into (nXAD, rXAD) */
if (newpage) {
/* close out old page */
if (!test_cflag(COMMIT_Nolink, ip)) {
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(index0, (int)xtlck->lwm.offset) : index0;
xtlck->lwm.length =
le16_to_cpu(p->header.nextindex) -
xtlck->lwm.offset;
}
bn = le64_to_cpu(p->header.next);
XT_PUTPAGE(mp);
/* get new right page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
index0 = index = newindex;
} else
index++;
newindex = index + 1;
nextindex = le16_to_cpu(p->header.nextindex);
xlen = xlen - (nxoff - xoff);
xoff = nxoff;
xaddr = nxaddr;
/* recompute split pages */
if (nextindex == le16_to_cpu(p->header.maxentry)) {
XT_PUTPAGE(mp);
if ((rc = xtSearch(ip, nxoff, NULL, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index0);
if (cmp != 0) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "xtSearch failed\n");
return -EIO;
}
if (index0 != index) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "unexpected value of index\n");
return -EIO;
}
}
/*
* split XAD into (nXAD, rXAD)
*
* ---nXAD---|
* --|----------XAD----------|--
* |-rXAD-|
*/
updateLeft: /* (nxoff == xoff) && (nxlen < xlen) */
/* update old XAD with nXAD:recorded */
xad = &p->xad[index];
*xad = *nxad;
xad->flag = xflag & ~XAD_NOTRECORDED;
/* insert rXAD:not_recorded */
xoff = xoff + nxlen;
xlen = xlen - nxlen;
xaddr = xaddr + nxlen;
if (nextindex == le16_to_cpu(p->header.maxentry)) {
/*
printf("xtUpdate.updateLeft.split p:0x%p\n", p);
*/
/* xtSpliUp() unpins leaf pages */
split.mp = mp;
split.index = newindex;
split.flag = xflag;
split.off = xoff;
split.len = xlen;
split.addr = xaddr;
split.pxdlist = NULL;
if ((rc = xtSplitUp(tid, ip, &split, &btstack)))
return rc;
/* get back old page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* if leaf root has been split, original root has been
* copied to new child page, i.e., original entry now
* resides on the new child page;
*/
if (p->header.flag & BT_INTERNAL) {
ASSERT(p->header.nextindex ==
cpu_to_le16(XTENTRYSTART + 1));
xad = &p->xad[XTENTRYSTART];
bn = addressXAD(xad);
XT_PUTPAGE(mp);
/* get new child page */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
BT_MARK_DIRTY(mp, ip);
if (!test_cflag(COMMIT_Nolink, ip)) {
tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
}
}
} else {
/* if insert into middle, shift right remaining entries */
if (newindex < nextindex)
memmove(&p->xad[newindex + 1], &p->xad[newindex],
(nextindex - newindex) << L2XTSLOTSIZE);
/* insert the entry */
xad = &p->xad[newindex];
XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);
/* advance next available entry index. */
p->header.nextindex =
cpu_to_le16(le16_to_cpu(p->header.nextindex) + 1);
}
out:
if (!test_cflag(COMMIT_Nolink, ip)) {
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(index0, (int)xtlck->lwm.offset) : index0;
xtlck->lwm.length = le16_to_cpu(p->header.nextindex) -
xtlck->lwm.offset;
}
/* unpin the leaf page */
XT_PUTPAGE(mp);
return rc;
}
/*
* xtAppend()
*
* function: grow in append mode from contiguous region specified ;
*
* parameter:
* tid - transaction id;
* ip - file object;
* xflag - extent flag:
* xoff - extent offset;
* maxblocks - max extent length;
* xlen - extent length (in/out);
* xaddrp - extent address pointer (in/out):
* flag -
*
* return:
*/
int xtAppend(tid_t tid, /* transaction id */
struct inode *ip, int xflag, s64 xoff, s32 maxblocks,
s32 * xlenp, /* (in/out) */
s64 * xaddrp, /* (in/out) */
int flag)
{
int rc = 0;
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* base B+-tree index page */
s64 bn, xaddr;
int index, nextindex;
struct btstack btstack; /* traverse stack */
struct xtsplit split; /* split information */
xad_t *xad;
int cmp;
struct tlock *tlck;
struct xtlock *xtlck;
int nsplit, nblocks, xlen;
struct pxdlist pxdlist;
pxd_t *pxd;
s64 next;
xaddr = *xaddrp;
xlen = *xlenp;
jfs_info("xtAppend: xoff:0x%lx maxblocks:%d xlen:%d xaddr:0x%lx",
(ulong) xoff, maxblocks, xlen, (ulong) xaddr);
/*
* search for the entry location at which to insert:
*
* xtFastSearch() and xtSearch() both returns (leaf page
* pinned, index at which to insert).
* n.b. xtSearch() may return index of maxentry of
* the full page.
*/
if ((rc = xtSearch(ip, xoff, &next, &cmp, &btstack, XT_INSERT)))
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
if (cmp == 0) {
rc = -EEXIST;
goto out;
}
if (next)
xlen = min(xlen, (int)(next - xoff));
//insert:
/*
* insert entry for new extent
*/
xflag |= XAD_NEW;
/*
* if the leaf page is full, split the page and
* propagate up the router entry for the new page from split
*
* The xtSplitUp() will insert the entry and unpin the leaf page.
*/
nextindex = le16_to_cpu(p->header.nextindex);
if (nextindex < le16_to_cpu(p->header.maxentry))
goto insertLeaf;
/*
* allocate new index blocks to cover index page split(s)
*/
nsplit = btstack.nsplit;
split.pxdlist = &pxdlist;
pxdlist.maxnpxd = pxdlist.npxd = 0;
pxd = &pxdlist.pxd[0];
nblocks = JFS_SBI(ip->i_sb)->nbperpage;
for (; nsplit > 0; nsplit--, pxd++, xaddr += nblocks, maxblocks -= nblocks) {
if ((rc = dbAllocBottomUp(ip, xaddr, (s64) nblocks)) == 0) {
PXDaddress(pxd, xaddr);
PXDlength(pxd, nblocks);
pxdlist.maxnpxd++;
continue;
}
/* undo allocation */
goto out;
}
xlen = min(xlen, maxblocks);
/*
* allocate data extent requested
*/
if ((rc = dbAllocBottomUp(ip, xaddr, (s64) xlen)))
goto out;
split.mp = mp;
split.index = index;
split.flag = xflag;
split.off = xoff;
split.len = xlen;
split.addr = xaddr;
if ((rc = xtSplitUp(tid, ip, &split, &btstack))) {
/* undo data extent allocation */
dbFree(ip, *xaddrp, (s64) * xlenp);
return rc;
}
*xaddrp = xaddr;
*xlenp = xlen;
return 0;
/*
* insert the new entry into the leaf page
*/
insertLeaf:
/*
* allocate data extent requested
*/
if ((rc = dbAllocBottomUp(ip, xaddr, (s64) xlen)))
goto out;
BT_MARK_DIRTY(mp, ip);
/*
* acquire a transaction lock on the leaf page;
*
* action: xad insertion/extension;
*/
tlck = txLock(tid, ip, mp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
/* insert the new entry: mark the entry NEW */
xad = &p->xad[index];
XT_PUTENTRY(xad, xflag, xoff, xlen, xaddr);
/* advance next available entry index */
le16_add_cpu(&p->header.nextindex, 1);
xtlck->lwm.offset =
(xtlck->lwm.offset) ? min(index,(int) xtlck->lwm.offset) : index;
xtlck->lwm.length = le16_to_cpu(p->header.nextindex) -
xtlck->lwm.offset;
*xaddrp = xaddr;
*xlenp = xlen;
out:
/* unpin the leaf page */
XT_PUTPAGE(mp);
return rc;
}
#ifdef _STILL_TO_PORT
/* - TBD for defragmentaion/reorganization -
*
* xtDelete()
*
* function:
* delete the entry with the specified key.
*
* N.B.: whole extent of the entry is assumed to be deleted.
*
* parameter:
*
* return:
* ENOENT: if the entry is not found.
*
* exception:
*/
int xtDelete(tid_t tid, struct inode *ip, s64 xoff, s32 xlen, int flag)
{
int rc = 0;
struct btstack btstack;
int cmp;
s64 bn;
struct metapage *mp;
xtpage_t *p;
int index, nextindex;
struct tlock *tlck;
struct xtlock *xtlck;
/*
* find the matching entry; xtSearch() pins the page
*/
if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
return rc;
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
if (cmp) {
/* unpin the leaf page */
XT_PUTPAGE(mp);
return -ENOENT;
}
/*
* delete the entry from the leaf page
*/
nextindex = le16_to_cpu(p->header.nextindex);
le16_add_cpu(&p->header.nextindex, -1);
/*
* if the leaf page bocome empty, free the page
*/
if (p->header.nextindex == cpu_to_le16(XTENTRYSTART))
return (xtDeleteUp(tid, ip, mp, p, &btstack));
BT_MARK_DIRTY(mp, ip);
/*
* acquire a transaction lock on the leaf page;
*
* action:xad deletion;
*/
tlck = txLock(tid, ip, mp, tlckXTREE);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset =
(xtlck->lwm.offset) ? min(index, xtlck->lwm.offset) : index;
/* if delete from middle, shift left/compact the remaining entries */
if (index < nextindex - 1)
memmove(&p->xad[index], &p->xad[index + 1],
(nextindex - index - 1) * sizeof(xad_t));
XT_PUTPAGE(mp);
return 0;
}
/* - TBD for defragmentaion/reorganization -
*
* xtDeleteUp()
*
* function:
* free empty pages as propagating deletion up the tree
*
* parameter:
*
* return:
*/
static int
xtDeleteUp(tid_t tid, struct inode *ip,
struct metapage * fmp, xtpage_t * fp, struct btstack * btstack)
{
int rc = 0;
struct metapage *mp;
xtpage_t *p;
int index, nextindex;
s64 xaddr;
int xlen;
struct btframe *parent;
struct tlock *tlck;
struct xtlock *xtlck;
/*
* keep root leaf page which has become empty
*/
if (fp->header.flag & BT_ROOT) {
/* keep the root page */
fp->header.flag &= ~BT_INTERNAL;
fp->header.flag |= BT_LEAF;
fp->header.nextindex = cpu_to_le16(XTENTRYSTART);
/* XT_PUTPAGE(fmp); */
return 0;
}
/*
* free non-root leaf page
*/
if ((rc = xtRelink(tid, ip, fp))) {
XT_PUTPAGE(fmp);
return rc;
}
xaddr = addressPXD(&fp->header.self);
xlen = lengthPXD(&fp->header.self);
/* free the page extent */
dbFree(ip, xaddr, (s64) xlen);
/* free the buffer page */
discard_metapage(fmp);
/*
* propagate page deletion up the index tree
*
* If the delete from the parent page makes it empty,
* continue all the way up the tree.
* stop if the root page is reached (which is never deleted) or
* if the entry deletion does not empty the page.
*/
while ((parent = BT_POP(btstack)) != NULL) {
/* get/pin the parent page <sp> */
XT_GETPAGE(ip, parent->bn, mp, PSIZE, p, rc);
if (rc)
return rc;
index = parent->index;
/* delete the entry for the freed child page from parent.
*/
nextindex = le16_to_cpu(p->header.nextindex);
/*
* the parent has the single entry being deleted:
* free the parent page which has become empty.
*/
if (nextindex == 1) {
if (p->header.flag & BT_ROOT) {
/* keep the root page */
p->header.flag &= ~BT_INTERNAL;
p->header.flag |= BT_LEAF;
p->header.nextindex =
cpu_to_le16(XTENTRYSTART);
/* XT_PUTPAGE(mp); */
break;
} else {
/* free the parent page */
if ((rc = xtRelink(tid, ip, p)))
return rc;
xaddr = addressPXD(&p->header.self);
/* free the page extent */
dbFree(ip, xaddr,
(s64) JFS_SBI(ip->i_sb)->nbperpage);
/* unpin/free the buffer page */
discard_metapage(mp);
/* propagate up */
continue;
}
}
/*
* the parent has other entries remaining:
* delete the router entry from the parent page.
*/
else {
BT_MARK_DIRTY(mp, ip);
/*
* acquire a transaction lock on the leaf page;
*
* action:xad deletion;
*/
tlck = txLock(tid, ip, mp, tlckXTREE);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->lwm.offset =
(xtlck->lwm.offset) ? min(index,
xtlck->lwm.
offset) : index;
/* if delete from middle,
* shift left/compact the remaining entries in the page
*/
if (index < nextindex - 1)
memmove(&p->xad[index], &p->xad[index + 1],
(nextindex - index -
1) << L2XTSLOTSIZE);
le16_add_cpu(&p->header.nextindex, -1);
jfs_info("xtDeleteUp(entry): 0x%lx[%d]",
(ulong) parent->bn, index);
}
/* unpin the parent page */
XT_PUTPAGE(mp);
/* exit propagation up */
break;
}
return 0;
}
/*
* NAME: xtRelocate()
*
* FUNCTION: relocate xtpage or data extent of regular file;
* This function is mainly used by defragfs utility.
*
* NOTE: This routine does not have the logic to handle
* uncommitted allocated extent. The caller should call
* txCommit() to commit all the allocation before call
* this routine.
*/
int
xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */
s64 nxaddr, /* new xaddr */
int xtype)
{ /* extent type: XTPAGE or DATAEXT */
int rc = 0;
struct tblock *tblk;
struct tlock *tlck;
struct xtlock *xtlck;
struct metapage *mp, *pmp, *lmp, *rmp; /* meta-page buffer */
xtpage_t *p, *pp, *rp, *lp; /* base B+-tree index page */
xad_t *xad;
pxd_t *pxd;
s64 xoff, xsize;
int xlen;
s64 oxaddr, sxaddr, dxaddr, nextbn, prevbn;
cbuf_t *cp;
s64 offset, nbytes, nbrd, pno;
int nb, npages, nblks;
s64 bn;
int cmp;
int index;
struct pxd_lock *pxdlock;
struct btstack btstack; /* traverse stack */
xtype = xtype & EXTENT_TYPE;
xoff = offsetXAD(oxad);
oxaddr = addressXAD(oxad);
xlen = lengthXAD(oxad);
/* validate extent offset */
offset = xoff << JFS_SBI(ip->i_sb)->l2bsize;
if (offset >= ip->i_size)
return -ESTALE; /* stale extent */
jfs_info("xtRelocate: xtype:%d xoff:0x%lx xlen:0x%x xaddr:0x%lx:0x%lx",
xtype, (ulong) xoff, xlen, (ulong) oxaddr, (ulong) nxaddr);
/*
* 1. get and validate the parent xtpage/xad entry
* covering the source extent to be relocated;
*/
if (xtype == DATAEXT) {
/* search in leaf entry */
rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
if (rc)
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index);
if (cmp) {
XT_PUTPAGE(pmp);
return -ESTALE;
}
/* validate for exact match with a single entry */
xad = &pp->xad[index];
if (addressXAD(xad) != oxaddr || lengthXAD(xad) != xlen) {
XT_PUTPAGE(pmp);
return -ESTALE;
}
} else { /* (xtype == XTPAGE) */
/* search in internal entry */
rc = xtSearchNode(ip, oxad, &cmp, &btstack, 0);
if (rc)
return rc;
/* retrieve search result */
XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index);
if (cmp) {
XT_PUTPAGE(pmp);
return -ESTALE;
}
/* xtSearchNode() validated for exact match with a single entry
*/
xad = &pp->xad[index];
}
jfs_info("xtRelocate: parent xad entry validated.");
/*
* 2. relocate the extent
*/
if (xtype == DATAEXT) {
/* if the extent is allocated-but-not-recorded
* there is no real data to be moved in this extent,
*/
if (xad->flag & XAD_NOTRECORDED)
goto out;
else
/* release xtpage for cmRead()/xtLookup() */
XT_PUTPAGE(pmp);
/*
* cmRelocate()
*
* copy target data pages to be relocated;
*
* data extent must start at page boundary and
* multiple of page size (except the last data extent);
* read in each page of the source data extent into cbuf,
* update the cbuf extent descriptor of the page to be
* homeward bound to new dst data extent
* copy the data from the old extent to new extent.
* copy is essential for compressed files to avoid problems
* that can arise if there was a change in compression
* algorithms.
* it is a good strategy because it may disrupt cache
* policy to keep the pages in memory afterwards.
*/
offset = xoff << JFS_SBI(ip->i_sb)->l2bsize;
assert((offset & CM_OFFSET) == 0);
nbytes = xlen << JFS_SBI(ip->i_sb)->l2bsize;
pno = offset >> CM_L2BSIZE;
npages = (nbytes + (CM_BSIZE - 1)) >> CM_L2BSIZE;
/*
npages = ((offset + nbytes - 1) >> CM_L2BSIZE) -
(offset >> CM_L2BSIZE) + 1;
*/
sxaddr = oxaddr;
dxaddr = nxaddr;
/* process the request one cache buffer at a time */
for (nbrd = 0; nbrd < nbytes; nbrd += nb,
offset += nb, pno++, npages--) {
/* compute page size */
nb = min(nbytes - nbrd, CM_BSIZE);
/* get the cache buffer of the page */
if (rc = cmRead(ip, offset, npages, &cp))
break;
assert(addressPXD(&cp->cm_pxd) == sxaddr);
assert(!cp->cm_modified);
/* bind buffer with the new extent address */
nblks = nb >> JFS_IP(ip->i_sb)->l2bsize;
cmSetXD(ip, cp, pno, dxaddr, nblks);
/* release the cbuf, mark it as modified */
cmPut(cp, true);
dxaddr += nblks;
sxaddr += nblks;
}
/* get back parent page */
if ((rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0)))
return rc;
XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index);
jfs_info("xtRelocate: target data extent relocated.");
} else { /* (xtype == XTPAGE) */
/*
* read in the target xtpage from the source extent;
*/
XT_GETPAGE(ip, oxaddr, mp, PSIZE, p, rc);
if (rc) {
XT_PUTPAGE(pmp);
return rc;
}
/*
* read in sibling pages if any to update sibling pointers;
*/
rmp = NULL;
if (p->header.next) {
nextbn = le64_to_cpu(p->header.next);
XT_GETPAGE(ip, nextbn, rmp, PSIZE, rp, rc);
if (rc) {
XT_PUTPAGE(pmp);
XT_PUTPAGE(mp);
return (rc);
}
}
lmp = NULL;
if (p->header.prev) {
prevbn = le64_to_cpu(p->header.prev);
XT_GETPAGE(ip, prevbn, lmp, PSIZE, lp, rc);
if (rc) {
XT_PUTPAGE(pmp);
XT_PUTPAGE(mp);
if (rmp)
XT_PUTPAGE(rmp);
return (rc);
}
}
/* at this point, all xtpages to be updated are in memory */
/*
* update sibling pointers of sibling xtpages if any;
*/
if (lmp) {
BT_MARK_DIRTY(lmp, ip);
tlck = txLock(tid, ip, lmp, tlckXTREE | tlckRELINK);
lp->header.next = cpu_to_le64(nxaddr);
XT_PUTPAGE(lmp);
}
if (rmp) {
BT_MARK_DIRTY(rmp, ip);
tlck = txLock(tid, ip, rmp, tlckXTREE | tlckRELINK);
rp->header.prev = cpu_to_le64(nxaddr);
XT_PUTPAGE(rmp);
}
/*
* update the target xtpage to be relocated
*
* update the self address of the target page
* and write to destination extent;
* redo image covers the whole xtpage since it is new page
* to the destination extent;
* update of bmap for the free of source extent
* of the target xtpage itself:
* update of bmap for the allocation of destination extent
* of the target xtpage itself:
* update of bmap for the extents covered by xad entries in
* the target xtpage is not necessary since they are not
* updated;
* if not committed before this relocation,
* target page may contain XAD_NEW entries which must
* be scanned for bmap update (logredo() always
* scan xtpage REDOPAGE image for bmap update);
* if committed before this relocation (tlckRELOCATE),
* scan may be skipped by commit() and logredo();
*/
BT_MARK_DIRTY(mp, ip);
/* tlckNEW init xtlck->lwm.offset = XTENTRYSTART; */
tlck = txLock(tid, ip, mp, tlckXTREE | tlckNEW);
xtlck = (struct xtlock *) & tlck->lock;
/* update the self address in the xtpage header */
pxd = &p->header.self;
PXDaddress(pxd, nxaddr);
/* linelock for the after image of the whole page */
xtlck->lwm.length =
le16_to_cpu(p->header.nextindex) - xtlck->lwm.offset;
/* update the buffer extent descriptor of target xtpage */
xsize = xlen << JFS_SBI(ip->i_sb)->l2bsize;
bmSetXD(mp, nxaddr, xsize);
/* unpin the target page to new homeward bound */
XT_PUTPAGE(mp);
jfs_info("xtRelocate: target xtpage relocated.");
}
/*
* 3. acquire maplock for the source extent to be freed;
*
* acquire a maplock saving the src relocated extent address;
* to free of the extent at commit time;
*/
out:
/* if DATAEXT relocation, write a LOG_UPDATEMAP record for
* free PXD of the source data extent (logredo() will update
* bmap for free of source data extent), and update bmap for
* free of the source data extent;
*/
if (xtype == DATAEXT)
tlck = txMaplock(tid, ip, tlckMAP);
/* if XTPAGE relocation, write a LOG_NOREDOPAGE record
* for the source xtpage (logredo() will init NoRedoPage
* filter and will also update bmap for free of the source
* xtpage), and update bmap for free of the source xtpage;
* N.B. We use tlckMAP instead of tlkcXTREE because there
* is no buffer associated with this lock since the buffer
* has been redirected to the target location.
*/
else /* (xtype == XTPAGE) */
tlck = txMaplock(tid, ip, tlckMAP | tlckRELOCATE);
pxdlock = (struct pxd_lock *) & tlck->lock;
pxdlock->flag = mlckFREEPXD;
PXDaddress(&pxdlock->pxd, oxaddr);
PXDlength(&pxdlock->pxd, xlen);
pxdlock->index = 1;
/*
* 4. update the parent xad entry for relocation;
*
* acquire tlck for the parent entry with XAD_NEW as entry
* update which will write LOG_REDOPAGE and update bmap for
* allocation of XAD_NEW destination extent;
*/
jfs_info("xtRelocate: update parent xad entry.");
BT_MARK_DIRTY(pmp, ip);
tlck = txLock(tid, ip, pmp, tlckXTREE | tlckGROW);
xtlck = (struct xtlock *) & tlck->lock;
/* update the XAD with the new destination extent; */
xad = &pp->xad[index];
xad->flag |= XAD_NEW;
XADaddress(xad, nxaddr);
xtlck->lwm.offset = min(index, xtlck->lwm.offset);
xtlck->lwm.length = le16_to_cpu(pp->header.nextindex) -
xtlck->lwm.offset;
/* unpin the parent xtpage */
XT_PUTPAGE(pmp);
return rc;
}
/*
* xtSearchNode()
*
* function: search for the internal xad entry covering specified extent.
* This function is mainly used by defragfs utility.
*
* parameters:
* ip - file object;
* xad - extent to find;
* cmpp - comparison result:
* btstack - traverse stack;
* flag - search process flag;
*
* returns:
* btstack contains (bn, index) of search path traversed to the entry.
* *cmpp is set to result of comparison with the entry returned.
* the page containing the entry is pinned at exit.
*/
static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */
int *cmpp, struct btstack * btstack, int flag)
{
int rc = 0;
s64 xoff, xaddr;
int xlen;
int cmp = 1; /* init for empty page */
s64 bn; /* block number */
struct metapage *mp; /* meta-page buffer */
xtpage_t *p; /* page */
int base, index, lim;
struct btframe *btsp;
s64 t64;
BT_CLR(btstack);
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
xaddr = addressXAD(xad);
/*
* search down tree from root:
*
* between two consecutive entries of <Ki, Pi> and <Kj, Pj> of
* internal page, child page Pi contains entry with k, Ki <= K < Kj.
*
* if entry with search key K is not found
* internal page search find the entry with largest key Ki
* less than K which point to the child page to search;
* leaf page search find the entry with smallest key Kj
* greater than K so that the returned index is the position of
* the entry to be shifted right for insertion of new entry.
* for empty tree, search key is greater than any key of the tree.
*
* by convention, root bn = 0.
*/
for (bn = 0;;) {
/* get/pin the page to search */
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
if (p->header.flag & BT_LEAF) {
XT_PUTPAGE(mp);
return -ESTALE;
}
lim = le16_to_cpu(p->header.nextindex) - XTENTRYSTART;
/*
* binary search with search key K on the current page
*/
for (base = XTENTRYSTART; lim; lim >>= 1) {
index = base + (lim >> 1);
XT_CMP(cmp, xoff, &p->xad[index], t64);
if (cmp == 0) {
/*
* search hit
*
* verify for exact match;
*/
if (xaddr == addressXAD(&p->xad[index]) &&
xoff == offsetXAD(&p->xad[index])) {
*cmpp = cmp;
/* save search result */
btsp = btstack->top;
btsp->bn = bn;
btsp->index = index;
btsp->mp = mp;
return 0;
}
/* descend/search its child page */
goto next;
}
if (cmp > 0) {
base = index + 1;
--lim;
}
}
/*
* search miss - non-leaf page:
*
* base is the smallest index with key (Kj) greater than
* search key (K) and may be zero or maxentry index.
* if base is non-zero, decrement base by one to get the parent
* entry of the child page to search.
*/
index = base ? base - 1 : base;
/*
* go down to child page
*/
next:
/* get the child page block number */
bn = addressXAD(&p->xad[index]);
/* unpin the parent page */
XT_PUTPAGE(mp);
}
}
/*
* xtRelink()
*
* function:
* link around a freed page.
*
* Parameter:
* int tid,
* struct inode *ip,
* xtpage_t *p)
*
* returns:
*/
static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * p)
{
int rc = 0;
struct metapage *mp;
s64 nextbn, prevbn;
struct tlock *tlck;
nextbn = le64_to_cpu(p->header.next);
prevbn = le64_to_cpu(p->header.prev);
/* update prev pointer of the next page */
if (nextbn != 0) {
XT_GETPAGE(ip, nextbn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* acquire a transaction lock on the page;
*
* action: update prev pointer;
*/
BT_MARK_DIRTY(mp, ip);
tlck = txLock(tid, ip, mp, tlckXTREE | tlckRELINK);
/* the page may already have been tlock'd */
p->header.prev = cpu_to_le64(prevbn);
XT_PUTPAGE(mp);
}
/* update next pointer of the previous page */
if (prevbn != 0) {
XT_GETPAGE(ip, prevbn, mp, PSIZE, p, rc);
if (rc)
return rc;
/*
* acquire a transaction lock on the page;
*
* action: update next pointer;
*/
BT_MARK_DIRTY(mp, ip);
tlck = txLock(tid, ip, mp, tlckXTREE | tlckRELINK);
/* the page may already have been tlock'd */
p->header.next = le64_to_cpu(nextbn);
XT_PUTPAGE(mp);
}
return 0;
}
#endif /* _STILL_TO_PORT */
/*
* xtInitRoot()
*
* initialize file root (inline in inode)
*/
void xtInitRoot(tid_t tid, struct inode *ip)
{
xtpage_t *p;
/*
* acquire a transaction lock on the root
*
* action:
*/
txLock(tid, ip, (struct metapage *) &JFS_IP(ip)->bxflag,
tlckXTREE | tlckNEW);
p = &JFS_IP(ip)->i_xtroot;
p->header.flag = DXD_INDEX | BT_ROOT | BT_LEAF;
p->header.nextindex = cpu_to_le16(XTENTRYSTART);
if (S_ISDIR(ip->i_mode))
p->header.maxentry = cpu_to_le16(XTROOTINITSLOT_DIR);
else {
p->header.maxentry = cpu_to_le16(XTROOTINITSLOT);
ip->i_size = 0;
}
return;
}
/*
* We can run into a deadlock truncating a file with a large number of
* xtree pages (large fragmented file). A robust fix would entail a
* reservation system where we would reserve a number of metadata pages
* and tlocks which we would be guaranteed without a deadlock. Without
* this, a partial fix is to limit number of metadata pages we will lock
* in a single transaction. Currently we will truncate the file so that
* no more than 50 leaf pages will be locked. The caller of xtTruncate
* will be responsible for ensuring that the current transaction gets
* committed, and that subsequent transactions are created to truncate
* the file further if needed.
*/
#define MAX_TRUNCATE_LEAVES 50
/*
* xtTruncate()
*
* function:
* traverse for truncation logging backward bottom up;
* terminate at the last extent entry at the current subtree
* root page covering new down size.
* truncation may occur within the last extent entry.
*
* parameter:
* int tid,
* struct inode *ip,
* s64 newsize,
* int type) {PWMAP, PMAP, WMAP; DELETE, TRUNCATE}
*
* return:
*
* note:
* PWMAP:
* 1. truncate (non-COMMIT_NOLINK file)
* by jfs_truncate() or jfs_open(O_TRUNC):
* xtree is updated;
* 2. truncate index table of directory when last entry removed
* map update via tlock at commit time;
* PMAP:
* Call xtTruncate_pmap instead
* WMAP:
* 1. remove (free zero link count) on last reference release
* (pmap has been freed at commit zero link count);
* 2. truncate (COMMIT_NOLINK file, i.e., tmp file):
* xtree is updated;
* map update directly at truncation time;
*
* if (DELETE)
* no LOG_NOREDOPAGE is required (NOREDOFILE is sufficient);
* else if (TRUNCATE)
* must write LOG_NOREDOPAGE for deleted index page;
*
* pages may already have been tlocked by anonymous transactions
* during file growth (i.e., write) before truncation;
*
* except last truncated entry, deleted entries remains as is
* in the page (nextindex is updated) for other use
* (e.g., log/update allocation map): this avoid copying the page
* info but delay free of pages;
*
*/
s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag)
{
int rc = 0;
s64 teof;
struct metapage *mp;
xtpage_t *p;
s64 bn;
int index, nextindex;
xad_t *xad;
s64 xoff, xaddr;
int xlen, len, freexlen;
struct btstack btstack;
struct btframe *parent;
struct tblock *tblk = NULL;
struct tlock *tlck = NULL;
struct xtlock *xtlck = NULL;
struct xdlistlock xadlock; /* maplock for COMMIT_WMAP */
struct pxd_lock *pxdlock; /* maplock for COMMIT_WMAP */
s64 nfreed;
int freed, log;
int locked_leaves = 0;
/* save object truncation type */
if (tid) {
tblk = tid_to_tblock(tid);
tblk->xflag |= flag;
}
nfreed = 0;
flag &= COMMIT_MAP;
assert(flag != COMMIT_PMAP);
if (flag == COMMIT_PWMAP)
log = 1;
else {
log = 0;
xadlock.flag = mlckFREEXADLIST;
xadlock.index = 1;
}
/*
* if the newsize is not an integral number of pages,
* the file between newsize and next page boundary will
* be cleared.
* if truncating into a file hole, it will cause
* a full block to be allocated for the logical block.
*/
/*
* release page blocks of truncated region <teof, eof>
*
* free the data blocks from the leaf index blocks.
* delete the parent index entries corresponding to
* the freed child data/index blocks.
* free the index blocks themselves which aren't needed
* in new sized file.
*
* index blocks are updated only if the blocks are to be
* retained in the new sized file.
* if type is PMAP, the data and index pages are NOT
* freed, and the data and index blocks are NOT freed
* from working map.
* (this will allow continued access of data/index of
* temporary file (zerolink count file truncated to zero-length)).
*/
teof = (newsize + (JFS_SBI(ip->i_sb)->bsize - 1)) >>
JFS_SBI(ip->i_sb)->l2bsize;
/* clear stack */
BT_CLR(&btstack);
/*
* start with root
*
* root resides in the inode
*/
bn = 0;
/*
* first access of each page:
*/
getPage:
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/* process entries backward from last index */
index = le16_to_cpu(p->header.nextindex) - 1;
/* Since this is the rightmost page at this level, and we may have
* already freed a page that was formerly to the right, let's make
* sure that the next pointer is zero.
*/
if (p->header.next) {
if (log)
/*
* Make sure this change to the header is logged.
* If we really truncate this leaf, the flag
* will be changed to tlckTRUNCATE
*/
tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW);
BT_MARK_DIRTY(mp, ip);
p->header.next = 0;
}
if (p->header.flag & BT_INTERNAL)
goto getChild;
/*
* leaf page
*/
freed = 0;
/* does region covered by leaf page precede Teof ? */
xad = &p->xad[index];
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
if (teof >= xoff + xlen) {
XT_PUTPAGE(mp);
goto getParent;
}
/* (re)acquire tlock of the leaf page */
if (log) {
if (++locked_leaves > MAX_TRUNCATE_LEAVES) {
/*
* We need to limit the size of the transaction
* to avoid exhausting pagecache & tlocks
*/
XT_PUTPAGE(mp);
newsize = (xoff + xlen) << JFS_SBI(ip->i_sb)->l2bsize;
goto getParent;
}
tlck = txLock(tid, ip, mp, tlckXTREE);
tlck->type = tlckXTREE | tlckTRUNCATE;
xtlck = (struct xtlock *) & tlck->lock;
xtlck->hwm.offset = le16_to_cpu(p->header.nextindex) - 1;
}
BT_MARK_DIRTY(mp, ip);
/*
* scan backward leaf page entries
*/
for (; index >= XTENTRYSTART; index--) {
xad = &p->xad[index];
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
xaddr = addressXAD(xad);
/*
* The "data" for a directory is indexed by the block
* device's address space. This metadata must be invalidated
* here
*/
if (S_ISDIR(ip->i_mode) && (teof == 0))
invalidate_xad_metapages(ip, *xad);
/*
* entry beyond eof: continue scan of current page
* xad
* ---|---=======------->
* eof
*/
if (teof < xoff) {
nfreed += xlen;
continue;
}
/*
* (xoff <= teof): last entry to be deleted from page;
* If other entries remain in page: keep and update the page.
*/
/*
* eof == entry_start: delete the entry
* xad
* -------|=======------->
* eof
*
*/
if (teof == xoff) {
nfreed += xlen;
if (index == XTENTRYSTART)
break;
nextindex = index;
}
/*
* eof within the entry: truncate the entry.
* xad
* -------===|===------->
* eof
*/
else if (teof < xoff + xlen) {
/* update truncated entry */
len = teof - xoff;
freexlen = xlen - len;
XADlength(xad, len);
/* save pxd of truncated extent in tlck */
xaddr += len;
if (log) { /* COMMIT_PWMAP */
xtlck->lwm.offset = (xtlck->lwm.offset) ?
min(index, (int)xtlck->lwm.offset) : index;
xtlck->lwm.length = index + 1 -
xtlck->lwm.offset;
xtlck->twm.offset = index;
pxdlock = (struct pxd_lock *) & xtlck->pxdlock;
pxdlock->flag = mlckFREEPXD;
PXDaddress(&pxdlock->pxd, xaddr);
PXDlength(&pxdlock->pxd, freexlen);
}
/* free truncated extent */
else { /* COMMIT_WMAP */
pxdlock = (struct pxd_lock *) & xadlock;
pxdlock->flag = mlckFREEPXD;
PXDaddress(&pxdlock->pxd, xaddr);
PXDlength(&pxdlock->pxd, freexlen);
txFreeMap(ip, pxdlock, NULL, COMMIT_WMAP);
/* reset map lock */
xadlock.flag = mlckFREEXADLIST;
}
/* current entry is new last entry; */
nextindex = index + 1;
nfreed += freexlen;
}
/*
* eof beyond the entry:
* xad
* -------=======---|--->
* eof
*/
else { /* (xoff + xlen < teof) */
nextindex = index + 1;
}
if (nextindex < le16_to_cpu(p->header.nextindex)) {
if (!log) { /* COMMIT_WAMP */
xadlock.xdlist = &p->xad[nextindex];
xadlock.count =
le16_to_cpu(p->header.nextindex) -
nextindex;
txFreeMap(ip, (struct maplock *) & xadlock,
NULL, COMMIT_WMAP);
}
p->header.nextindex = cpu_to_le16(nextindex);
}
XT_PUTPAGE(mp);
/* assert(freed == 0); */
goto getParent;
} /* end scan of leaf page entries */
freed = 1;
/*
* leaf page become empty: free the page if type != PMAP
*/
if (log) { /* COMMIT_PWMAP */
/* txCommit() with tlckFREE:
* free data extents covered by leaf [XTENTRYSTART:hwm);
* invalidate leaf if COMMIT_PWMAP;
* if (TRUNCATE), will write LOG_NOREDOPAGE;
*/
tlck->type = tlckXTREE | tlckFREE;
} else { /* COMMIT_WAMP */
/* free data extents covered by leaf */
xadlock.xdlist = &p->xad[XTENTRYSTART];
xadlock.count =
le16_to_cpu(p->header.nextindex) - XTENTRYSTART;
txFreeMap(ip, (struct maplock *) & xadlock, NULL, COMMIT_WMAP);
}
if (p->header.flag & BT_ROOT) {
p->header.flag &= ~BT_INTERNAL;
p->header.flag |= BT_LEAF;
p->header.nextindex = cpu_to_le16(XTENTRYSTART);
XT_PUTPAGE(mp); /* debug */
goto out;
} else {
if (log) { /* COMMIT_PWMAP */
/* page will be invalidated at tx completion
*/
XT_PUTPAGE(mp);
} else { /* COMMIT_WMAP */
if (mp->lid)
lid_to_tlock(mp->lid)->flag |= tlckFREELOCK;
/* invalidate empty leaf page */
discard_metapage(mp);
}
}
/*
* the leaf page become empty: delete the parent entry
* for the leaf page if the parent page is to be kept
* in the new sized file.
*/
/*
* go back up to the parent page
*/
getParent:
/* pop/restore parent entry for the current child page */
if ((parent = BT_POP(&btstack)) == NULL)
/* current page must have been root */
goto out;
/* get back the parent page */
bn = parent->bn;
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
index = parent->index;
/*
* child page was not empty:
*/
if (freed == 0) {
/* has any entry deleted from parent ? */
if (index < le16_to_cpu(p->header.nextindex) - 1) {
/* (re)acquire tlock on the parent page */
if (log) { /* COMMIT_PWMAP */
/* txCommit() with tlckTRUNCATE:
* free child extents covered by parent [);
*/
tlck = txLock(tid, ip, mp, tlckXTREE);
xtlck = (struct xtlock *) & tlck->lock;
if (!(tlck->type & tlckTRUNCATE)) {
xtlck->hwm.offset =
le16_to_cpu(p->header.
nextindex) - 1;
tlck->type =
tlckXTREE | tlckTRUNCATE;
}
} else { /* COMMIT_WMAP */
/* free child extents covered by parent */
xadlock.xdlist = &p->xad[index + 1];
xadlock.count =
le16_to_cpu(p->header.nextindex) -
index - 1;
txFreeMap(ip, (struct maplock *) & xadlock,
NULL, COMMIT_WMAP);
}
BT_MARK_DIRTY(mp, ip);
p->header.nextindex = cpu_to_le16(index + 1);
}
XT_PUTPAGE(mp);
goto getParent;
}
/*
* child page was empty:
*/
nfreed += lengthXAD(&p->xad[index]);
/*
* During working map update, child page's tlock must be handled
* before parent's. This is because the parent's tlock will cause
* the child's disk space to be marked available in the wmap, so
* it's important that the child page be released by that time.
*
* ToDo: tlocks should be on doubly-linked list, so we can
* quickly remove it and add it to the end.
*/
/*
* Move parent page's tlock to the end of the tid's tlock list
*/
if (log && mp->lid && (tblk->last != mp->lid) &&
lid_to_tlock(mp->lid)->tid) {
lid_t lid = mp->lid;
struct tlock *prev;
tlck = lid_to_tlock(lid);
if (tblk->next == lid)
tblk->next = tlck->next;
else {
for (prev = lid_to_tlock(tblk->next);
prev->next != lid;
prev = lid_to_tlock(prev->next)) {
assert(prev->next);
}
prev->next = tlck->next;
}
lid_to_tlock(tblk->last)->next = lid;
tlck->next = 0;
tblk->last = lid;
}
/*
* parent page become empty: free the page
*/
if (index == XTENTRYSTART) {
if (log) { /* COMMIT_PWMAP */
/* txCommit() with tlckFREE:
* free child extents covered by parent;
* invalidate parent if COMMIT_PWMAP;
*/
tlck = txLock(tid, ip, mp, tlckXTREE);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->hwm.offset =
le16_to_cpu(p->header.nextindex) - 1;
tlck->type = tlckXTREE | tlckFREE;
} else { /* COMMIT_WMAP */
/* free child extents covered by parent */
xadlock.xdlist = &p->xad[XTENTRYSTART];
xadlock.count =
le16_to_cpu(p->header.nextindex) -
XTENTRYSTART;
txFreeMap(ip, (struct maplock *) & xadlock, NULL,
COMMIT_WMAP);
}
BT_MARK_DIRTY(mp, ip);
if (p->header.flag & BT_ROOT) {
p->header.flag &= ~BT_INTERNAL;
p->header.flag |= BT_LEAF;
p->header.nextindex = cpu_to_le16(XTENTRYSTART);
if (le16_to_cpu(p->header.maxentry) == XTROOTMAXSLOT) {
/*
* Shrink root down to allow inline
* EA (otherwise fsck complains)
*/
p->header.maxentry =
cpu_to_le16(XTROOTINITSLOT);
JFS_IP(ip)->mode2 |= INLINEEA;
}
XT_PUTPAGE(mp); /* debug */
goto out;
} else {
if (log) { /* COMMIT_PWMAP */
/* page will be invalidated at tx completion
*/
XT_PUTPAGE(mp);
} else { /* COMMIT_WMAP */
if (mp->lid)
lid_to_tlock(mp->lid)->flag |=
tlckFREELOCK;
/* invalidate parent page */
discard_metapage(mp);
}
/* parent has become empty and freed:
* go back up to its parent page
*/
/* freed = 1; */
goto getParent;
}
}
/*
* parent page still has entries for front region;
*/
else {
/* try truncate region covered by preceding entry
* (process backward)
*/
index--;
/* go back down to the child page corresponding
* to the entry
*/
goto getChild;
}
/*
* internal page: go down to child page of current entry
*/
getChild:
/* save current parent entry for the child page */
if (BT_STACK_FULL(&btstack)) {
jfs_error(ip->i_sb, "stack overrun!\n");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(&btstack, bn, index);
/* get child page */
xad = &p->xad[index];
bn = addressXAD(xad);
/*
* first access of each internal entry:
*/
/* release parent page */
XT_PUTPAGE(mp);
/* process the child page */
goto getPage;
out:
/*
* update file resource stat
*/
/* set size
*/
if (S_ISDIR(ip->i_mode) && !newsize)
ip->i_size = 1; /* fsck hates zero-length directories */
else
ip->i_size = newsize;
/* update quota allocation to reflect freed blocks */
dquot_free_block(ip, nfreed);
/*
* free tlock of invalidated pages
*/
if (flag == COMMIT_WMAP)
txFreelock(ip);
return newsize;
}
/*
* xtTruncate_pmap()
*
* function:
* Perform truncate to zero length for deleted file, leaving the
* the xtree and working map untouched. This allows the file to
* be accessed via open file handles, while the delete of the file
* is committed to disk.
*
* parameter:
* tid_t tid,
* struct inode *ip,
* s64 committed_size)
*
* return: new committed size
*
* note:
*
* To avoid deadlock by holding too many transaction locks, the
* truncation may be broken up into multiple transactions.
* The committed_size keeps track of part of the file has been
* freed from the pmaps.
*/
s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
{
s64 bn;
struct btstack btstack;
int cmp;
int index;
int locked_leaves = 0;
struct metapage *mp;
xtpage_t *p;
struct btframe *parent;
int rc;
struct tblock *tblk;
struct tlock *tlck = NULL;
xad_t *xad;
int xlen;
s64 xoff;
struct xtlock *xtlck = NULL;
/* save object truncation type */
tblk = tid_to_tblock(tid);
tblk->xflag |= COMMIT_PMAP;
/* clear stack */
BT_CLR(&btstack);
if (committed_size) {
xoff = (committed_size >> JFS_SBI(ip->i_sb)->l2bsize) - 1;
rc = xtSearch(ip, xoff, NULL, &cmp, &btstack, 0);
if (rc)
return rc;
XT_GETSEARCH(ip, btstack.top, bn, mp, p, index);
if (cmp != 0) {
XT_PUTPAGE(mp);
jfs_error(ip->i_sb, "did not find extent\n");
return -EIO;
}
} else {
/*
* start with root
*
* root resides in the inode
*/
bn = 0;
/*
* first access of each page:
*/
getPage:
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
/* process entries backward from last index */
index = le16_to_cpu(p->header.nextindex) - 1;
if (p->header.flag & BT_INTERNAL)
goto getChild;
}
/*
* leaf page
*/
if (++locked_leaves > MAX_TRUNCATE_LEAVES) {
/*
* We need to limit the size of the transaction
* to avoid exhausting pagecache & tlocks
*/
xad = &p->xad[index];
xoff = offsetXAD(xad);
xlen = lengthXAD(xad);
XT_PUTPAGE(mp);
return (xoff + xlen) << JFS_SBI(ip->i_sb)->l2bsize;
}
tlck = txLock(tid, ip, mp, tlckXTREE);
tlck->type = tlckXTREE | tlckFREE;
xtlck = (struct xtlock *) & tlck->lock;
xtlck->hwm.offset = index;
XT_PUTPAGE(mp);
/*
* go back up to the parent page
*/
getParent:
/* pop/restore parent entry for the current child page */
if ((parent = BT_POP(&btstack)) == NULL)
/* current page must have been root */
goto out;
/* get back the parent page */
bn = parent->bn;
XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
if (rc)
return rc;
index = parent->index;
/*
* parent page become empty: free the page
*/
if (index == XTENTRYSTART) {
/* txCommit() with tlckFREE:
* free child extents covered by parent;
* invalidate parent if COMMIT_PWMAP;
*/
tlck = txLock(tid, ip, mp, tlckXTREE);
xtlck = (struct xtlock *) & tlck->lock;
xtlck->hwm.offset = le16_to_cpu(p->header.nextindex) - 1;
tlck->type = tlckXTREE | tlckFREE;
XT_PUTPAGE(mp);
if (p->header.flag & BT_ROOT) {
goto out;
} else {
goto getParent;
}
}
/*
* parent page still has entries for front region;
*/
else
index--;
/*
* internal page: go down to child page of current entry
*/
getChild:
/* save current parent entry for the child page */
if (BT_STACK_FULL(&btstack)) {
jfs_error(ip->i_sb, "stack overrun!\n");
XT_PUTPAGE(mp);
return -EIO;
}
BT_PUSH(&btstack, bn, index);
/* get child page */
xad = &p->xad[index];
bn = addressXAD(xad);
/*
* first access of each internal entry:
*/
/* release parent page */
XT_PUTPAGE(mp);
/* process the child page */
goto getPage;
out:
return 0;
}
#ifdef CONFIG_JFS_STATISTICS
static int jfs_xtstat_proc_show(struct seq_file *m, void *v)
{
seq_printf(m,
"JFS Xtree statistics\n"
"====================\n"
"searches = %d\n"
"fast searches = %d\n"
"splits = %d\n",
xtStat.search,
xtStat.fastSearch,
xtStat.split);
return 0;
}
static int jfs_xtstat_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, jfs_xtstat_proc_show, NULL);
}
const struct file_operations jfs_xtstat_proc_fops = {
.owner = THIS_MODULE,
.open = jfs_xtstat_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif
| {
"pile_set_name": "Github"
} |
"""Convert a NT pathname to a file URL and vice versa."""
def url2pathname(url):
"""OS-specific conversion from a relative URL of the 'file' scheme
to a file system path; not recommended for general use."""
# e.g.
# ///C|/foo/bar/spam.foo
# becomes
# C:\foo\bar\spam.foo
import string, urllib
# Windows itself uses ":" even in URLs.
url = url.replace(':', '|')
if not '|' in url:
# No drive specifier, just convert slashes
if url[:4] == '////':
# path is something like ////host/path/on/remote/host
# convert this to \\host\path\on\remote\host
# (notice halving of slashes at the start of the path)
url = url[2:]
components = url.split('/')
# make sure not to convert quoted slashes :-)
return urllib.unquote('\\'.join(components))
comp = url.split('|')
if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
error = 'Bad URL: ' + url
raise IOError, error
drive = comp[0][-1].upper()
path = drive + ':'
components = comp[1].split('/')
for comp in components:
if comp:
path = path + '\\' + urllib.unquote(comp)
# Issue #11474: url like '/C|/' should convert into 'C:\\'
if path.endswith(':') and url.endswith('/'):
path += '\\'
return path
def pathname2url(p):
"""OS-specific conversion from a file system path to a relative URL
of the 'file' scheme; not recommended for general use."""
# e.g.
# C:\foo\bar\spam.foo
# becomes
# ///C|/foo/bar/spam.foo
import urllib
if not ':' in p:
# No drive specifier, just convert slashes and quote the name
if p[:2] == '\\\\':
# path is something like \\host\path\on\remote\host
# convert this to ////host/path/on/remote/host
# (notice doubling of slashes at the start of the path)
p = '\\\\' + p
components = p.split('\\')
return urllib.quote('/'.join(components))
comp = p.split(':')
if len(comp) != 2 or len(comp[0]) > 1:
error = 'Bad path: ' + p
raise IOError, error
drive = urllib.quote(comp[0].upper())
components = comp[1].split('\\')
path = '///' + drive + ':'
for comp in components:
if comp:
path = path + '/' + urllib.quote(comp)
return path
| {
"pile_set_name": "Github"
} |
import withMessage from './withMessage';
global.expect = withMessage(global.expect);
| {
"pile_set_name": "Github"
} |
-- boundary1.test
--
-- db eval {
-- SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid
-- }
SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid | {
"pile_set_name": "Github"
} |
// +build 386
package ole
type VARIANT struct {
VT VT // 2
wReserved1 uint16 // 4
wReserved2 uint16 // 6
wReserved3 uint16 // 8
Val int64 // 16
}
| {
"pile_set_name": "Github"
} |
'use strict';
var global = require('./_global');
var core = require('./_core');
var dP = require('./_object-dp');
var DESCRIPTORS = require('./_descriptors');
var SPECIES = require('./_wks')('species');
module.exports = function (KEY) {
var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
configurable: true,
get: function () { return this; }
});
};
| {
"pile_set_name": "Github"
} |
Collection of econometric functions for performance and risk analysis.
This package aims to aid practitioners and researchers in utilizing
the latest research in analysis of non-normal return streams. In
general, it is most tested on return (rather than price) data on a
regular scale, but most functions will work with irregular return
data as well, and increasing numbers of functions will work with
P&L or price data where possible.
WWW: https://cran.r-project.org/web/packages/PerformanceAnalytics/
| {
"pile_set_name": "Github"
} |
# This Makefile is intended only for DJGPP use.
# It is mainly a copy of the main Makefile, but tends to get out of sync
# with it. A merge would probably be appropriate.
# Primary targets:
# gc.a - builds basic library
# libgc.a - builds library for use with g++ "-fgc-keyword" extension
# -fgc-keyword was never really available. Historical
# interest only.
# c++ - adds C++ interface to library
# cords - adds cords (heavyweight strings) to library
# test - prints porting information, then builds basic version of gc.a,
# and runs some tests of collector and cords. Does not add cords or
# c++ interface to gc.a
# cord/de$(EXE_SUFFIX) - builds dumb editor based on cords.
ABI_FLAG=
CC=gcc $(ABI_FLAG)
CXX=gxx $(ABI_FLAG)
AS=gcc -c -x assembler-with-cpp $(ABI_FLAG)
# The above doesn't work with gas, which doesn't run cpp.
# Define AS as `gcc -c -x assembler-with-cpp' instead.
# special defines for DJGPP
CXXLD=gxx $(ABI_FLAG)
EXE_SUFFIX=.exe
srcdir= .
VPATH= $(srcdir)
CFLAGS= -gstabs+ -O2 -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION
# Look into doc/README.macros for the description of the "define arguments"
# influencing the collector configuration.
CXXFLAGS= $(CFLAGS) -DGC_OPERATOR_NEW_ARRAY
AR= ar
RANLIB= ranlib
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o
CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c
CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
SRCS= $(CSRCS) mips_sgi_mach_dep.S rs6000_mach_dep.s alpha_mach_dep.S \
sparc_mach_dep.S include/gc.h include/gc_version.h include/gc_typed.h \
include/private/gc_hdrs.h include/private/gc_priv.h \
include/private/gcconfig.h include/private/gc_mark.h \
include/gc_inline.h gc.man extra/threadlibs.c \
extra/if_mach.c extra/if_not_there.c gc_cpp.cc include/gc_cpp.h \
include/weakpointer.h include/private/gc_locks.h \
gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
include/private/solaris_threads.h include/gc_backptr.h \
hpux_test_and_clear.s include/gc_gcj.h \
include/gc_local_alloc.h include/private/dbg_mlc.h \
include/private/specific.h \
include/leak_detector.h $(CORD_SRCS)
OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \
README tests/test.c test_cpp.cc extra/setjmp_t.c SMakefile.amiga \
SCoptions.amiga README.amiga README.win32 cord/README \
README.rs6000 README.QUICK callprocs pc_excludes \
barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \
extra/MacOS.c EMX_MAKEFILE README.debugging \
Mac_files/datastart.c Mac_files/dataend.c \
Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
extra/add_gc_prefix.c README.solaris2 README.sgi README.hp \
README.uts win32_threads.c gc.mak README.dj \
Makefile.dj README.alpha README.linux README.MacOSX Makefile.DLLs \
WCC_MAKEFILE
CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
$(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
UTILS= if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
# Libraries needed for curses applications. Only needed for de.
CURSES= -lcurses -ltermlib
# The following is irrelevant on most systems. But a few
# versions of make otherwise fork the shell specified in
# the SHELL environment variable.
SHELL= /bin/sh
SPECIALCFLAGS = -I$(srcdir)/include
# Alternative flags to the C compiler for mach_dep.c.
# Mach_dep.c often doesn't like optimization, and it's
# not time-critical anyway.
# Set SPECIALCFLAGS to -q nodirect_code on Encore.
all: gc.a gctest$(EXE_SUFFIX)
$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: \
$(srcdir)/include/private/gc_priv.h \
$(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
$(srcdir)/include/gc.h \
$(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
Makefile
# The dependency on Makefile is needed. Changing
# options affects the size of GC_arrays,
# invalidating all .o files that rely on gc_priv.h
mark.o typd_mlc.o finalize.o: $(srcdir)/include/gc_mark.h
base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
echo > base_lib
rm -f on_sparc_sunos5_1
./if_mach SPARC SOLARIS touch on_sparc_sunos5_1
./if_mach SPARC SOLARIS $(AR) rus gc.a $(OBJS) dyn_load.o
./if_not_there on_sparc_sunos5_1 $(AR) ru gc.a $(OBJS) dyn_load.o
-./if_not_there on_sparc_sunos5_1 $(RANLIB) gc.a
# ignore ranlib failure; that usually means it doesn't exist, and isn't needed
cords: $(CORD_OBJS) cord/cordtest$(EXE_SUFFIX) $(UTILS)
rm -f on_sparc_sunos5_3
./if_mach SPARC SOLARIS touch on_sparc_sunos5_3
./if_mach SPARC SOLARIS $(AR) rus gc.a $(CORD_OBJS)
./if_not_there on_sparc_sunos5_3 $(AR) ru gc.a $(CORD_OBJS)
-./if_not_there on_sparc_sunos5_3 $(RANLIB) gc.a
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
base_lib $(UTILS)
rm -f test_cpp test_cpp$(EXE_SUFFIX)
./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld
./if_not_there test_cpp$(EXE_SUFFIX) $(CXXLD) $(CXXFLAGS) -o test_cpp$(EXE_SUFFIX) $(srcdir)/test_cpp.cc gc_cpp.o gc.a
rm -f test_cpp
c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp$(EXE_SUFFIX)
rm -f on_sparc_sunos5_4
./if_mach SPARC SOLARIS touch on_sparc_sunos5_4
./if_mach SPARC SOLARIS $(AR) rus gc.a gc_cpp.o
./if_not_there on_sparc_sunos5_4 $(AR) ru gc.a gc_cpp.o
-./if_not_there on_sparc_sunos5_4 $(RANLIB) gc.a
./test_cpp$(EXE_SUFFIX) 1
echo > c++
dyn_load_sunos53.o: dyn_load.c
$(CC) $(CFLAGS) -DSUNOS53_SHARED_LIB -c $(srcdir)/dyn_load.c -o $@
# SunOS5 shared library version of the collector
sunos5gc.so: $(OBJS) dyn_load_sunos53.o
$(CC) -G -o sunos5gc.so $(OBJS) dyn_load_sunos53.o -ldl
ln sunos5gc.so libgc.so
# Alpha/OSF shared library version of the collector
libalphagc.so: $(OBJS)
ld -shared -o libalphagc.so $(OBJS) dyn_load.o -lc
ln libalphagc.so libgc.so
# IRIX shared library version of the collector
libirixgc.so: $(OBJS) dyn_load.o
ld -shared $(ABI_FLAG) -o libirixgc.so $(OBJS) dyn_load.o -lc
ln libirixgc.so libgc.so
# Linux shared library version of the collector
liblinuxgc.so: $(OBJS) dyn_load.o
gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo
ln liblinuxgc.so libgc.so
mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.S $(srcdir)/mips_ultrix_mach_dep.s \
$(srcdir)/rs6000_mach_dep.s $(UTILS)
rm -f mach_dep.o
./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.S
./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach POWERPC AIX $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.S
./if_mach SPARC SOLARIS $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.S
./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c
mark_rts.o: $(srcdir)/mark_rts.c if_mach if_not_there $(UTILS)
rm -f mark_rts.o
-./if_mach ALPHA OSF1 $(CC) -c $(CFLAGS) -Wo,-notail $(srcdir)/mark_rts.c
./if_not_there mark_rts.o $(CC) -c $(CFLAGS) $(srcdir)/mark_rts.c
# Work-around for DEC optimizer tail recursion elimination bug.
# The ALPHA-specific line should be removed if gcc is used.
alloc.o: include/gc_version.h
cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES)
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordbscs.c
mv cordbscs.o cord/cordbscs.o
# not all compilers understand -o filename
cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES)
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordxtra.c
mv cordxtra.o cord/cordxtra.o
cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES)
$(CC) $(CFLAGS) -c -I$(srcdir) $(srcdir)/cord/cordprnt.c
mv cordprnt.o cord/cordprnt.o
cord/cordtest$(EXE_SUFFIX): $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a $(UTILS) /tmp
rm -f cord/cordtest$(EXE_SUFFIX)
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/cordtest$(EXE_SUFFIX) $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -lucb
./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/cordtest$(EXE_SUFFIX) $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a -ldld
./if_not_there cord/cordtest$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/cordtest $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a
rm -f cord/cordtest cordtest
-mv cordtest$(EXE_SUFFIX) cord/
/tmp: $(UTILS)
./if_not_there /tmp mkdir /tmp
cord/de$(EXE_SUFFIX): $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS)
rm -f cord/de cord/de$(EXE_SUFFIX)
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs`
./if_mach HP_PA "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld
./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
./if_not_there cord/de$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/de$(EXE_SUFFIX) $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES)
if_mach$(EXE_SUFFIX): $(srcdir)/extra/if_mach.c $(srcdir)/include/private/gcconfig.h
rm -f if_mach if_mach$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o if_mach $(srcdir)/extra/if_mach.c
threadlibs$(EXE_SUFFIX): $(srcdir)/extra/threadlibs.c $(srcdir)include/private/gcconfig.h Makefile
rm -f threadlibs threadlibs$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o threadlibs $(srcdir)/extra/threadlibs.c
if_not_there$(EXE_SUFFIX): $(srcdir)/extra/if_not_there.c
rm -f if_not_there if_not_there$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o if_not_there $(srcdir)/extra/if_not_there.c
# Clean removes *.o several times,
# because as the first one doesn't seem to get them all!
clean:
rm -f gc.a *.o
rm -f *.o
rm -f *.o
rm -f cord/*.o
rm -f gctest gctest_dyn_link test_cpp
rm -f setjmp_test mon.out gmon.out a.out core if_not_there if_mach
rm -f threadlibs $(CORD_OBJS) cordtest cord/cordtest de cord/de
rm -f gctest$(EXE_SUFFIX) gctest_dyn_link$(EXE_SUFFIX) test_cpp$(EXE_SUFFIX)
rm -f setjmp_test$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX) if_mach$(EXE_SUFFIX)
rm -f threadlibs$(EXE_SUFFIX) cord/cordtest$(EXE_SUFFIX)
-rm -f *~
gctest$(EXE_SUFFIX): tests/test.o gc.a if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
rm -f gctest gctest$(EXE_SUFFIX)
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -lucb
./if_mach HP_PA "" $(CC) $(CFLAGS) -o gctest tests/test.o gc.a -ldld
./if_not_there gctest$(EXE_SUFFIX) $(CC) $(CFLAGS) -o gctest$(EXE_SUFFIX) tests/test.o gc.a
rm -f gctest
# If an optimized setjmp_test generates a segmentation fault,
# odds are your compiler is broken. Gctest may still work.
# Try compiling setjmp_t.c unoptimized.
setjmp_test$(EXE_SUFFIX): $(srcdir)/extra/setjmp_t.c $(srcdir)/include/gc.h \
if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
rm -f setjmp_test$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o setjmp_test $(srcdir)/extra/setjmp_t.c
rm -f setjmp_test
test: KandRtest cord/cordtest$(EXE_SUFFIX)
./cord/cordtest$(EXE_SUFFIX)
# Those tests that work even with a K&R C compiler:
KandRtest: setjmp_test$(EXE_SUFFIX) gctest$(EXE_SUFFIX)
./setjmp_test$(EXE_SUFFIX)
./gctest$(EXE_SUFFIX)
add_gc_prefix$(EXE_SUFFIX): extra/add_gc_prefix.c
$(CC) -o add_gc_prefix$(EXE_SUFFIX) $(srcdir)/extra/add_gc_prefix.c
rm -f add_gc_prefix
gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix
./add_gc_prefix$(EXE_SUFFIX) $(SRCS) $(OTHER_FILES) > /tmp/gc.tar-files
(cd $(srcdir)/.. ; tar cvfh - `cat /tmp/gc.tar-files`) > gc.tar
pc_gc.tar: $(SRCS) $(OTHER_FILES)
tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES)
gc.tar.Z: gc.tar
compress gc.tar
gc.tar.gz: gc.tar
gzip gc.tar
lint: $(CSRCS) tests/test.c
lint -DLINT $(CSRCS) tests/test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall"
# BTL: added to test shared library version of collector.
# Currently works only under SunOS5. Requires GC_INIT call from statically
# loaded client code.
ABSDIR = `pwd`
gctest_dyn_link: test.o libgc.so
$(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread
test_dll.o: tests/test.c libgc_globals.h
$(CC) $(CFLAGS) -DGC_USE_DLL -c tests/test.c -o test_dll.o
test_dll: test_dll.o libgc_dll.a libgc.dll
$(CC) test_dll.o -L$(ABSDIR) -lgc_dll -o test_dll
SYM_PREFIX-libgc=GC
# Uncomment the following line to build a GNU win32 DLL
# include Makefile.DLLs
| {
"pile_set_name": "Github"
} |
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl IPTables-Parse.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test;
BEGIN { plan tests => 1 };
use IPTables::Parse;
ok(1); # If we made it this far, we're ok.
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
| {
"pile_set_name": "Github"
} |
# Copyright (C) 2016 Red Hat, Inc., Pep Turro Mauri <[email protected]>
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, RedHatPlugin
import os.path
# This plugin collects static configuration and runtime information
# about OpenShift Origin based environments, like OpenShift Enterprise 3
# Some clarification on naming:
# OpenShift Origin is the upstream project for OpenShift Enterprise,
# OpenShift Container Platflorm, and Atomic Platform.
#
# However, the name "OpenShift Origin" refers to two different code bases:
# * Origin M5 and later (https://github.com/openshift/origin)
# which is upstream for OpenShift 3.x and later.
# This is what this plugin handles
# * Origin M4 and earlier (https://github.com/openshift/origin-server)
# which is upstream for OpenShift 1.x and 2.x.
# This is handled by the plugin in openshift.py
# Note that this plugin should be used in conjunction with other plugins
# in order to capture relevant data: the Kubernetes plugin for the
# masters, the Docker plugin for the nodes, and also generic
# plugins (e.g. for /etc/sysconfig entries, network setup etc)
class OpenShiftOrigin(Plugin):
short_desc = 'OpenShift Origin'
plugin_name = "origin"
files = None # file lists assigned after path setup below
profiles = ('openshift',)
option_list = [
("diag", "run 'oc adm diagnostics' to collect its output",
'fast', True),
("diag-prevent", "set --prevent-modification on 'oc adm diagnostics'",
'fast', True),
("all-namespaces", "collect dc output for all namespaces", "fast",
False)
]
master_base_dir = "/etc/origin/master"
node_base_dir = "/etc/origin/node"
master_cfg = os.path.join(master_base_dir, "master-config.yaml")
master_env = os.path.join(master_base_dir, "master.env")
node_cfg_file = "node-config.yaml"
node_cfg = os.path.join(node_base_dir, node_cfg_file)
node_kubeconfig = os.path.join(node_base_dir, "node.kubeconfig")
static_pod_dir = os.path.join(node_base_dir, "pods")
files = (master_cfg, node_cfg)
# Master vs. node
#
# OpenShift Origin/3.x cluster members can be a master, a node, or both at
# the same time: in most deployments masters are also nodes in order to get
# access to the pod network, which some functionality (e.g. the API proxy)
# requires. Therefore the following methods may all evaluate True on a
# single instance (at least one must evaluate True if this is an OpenShift
# installation)
def is_master(self):
"""Determine if we are on a master"""
return os.path.exists(self.master_cfg)
def is_node(self):
"""Determine if we are on a node"""
return os.path.exists(self.node_cfg)
def is_static_etcd(self):
"""Determine if we are on a node running etcd"""
return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
def is_static_pod_compatible(self):
"""Determine if a node is running static pods"""
return os.path.exists(self.static_pod_dir)
def setup(self):
bstrap_node_cfg = os.path.join(self.node_base_dir,
"bootstrap-" + self.node_cfg_file)
bstrap_kubeconfig = os.path.join(self.node_base_dir,
"bootstrap.kubeconfig")
node_certs = os.path.join(self.node_base_dir, "certs", "*")
node_client_ca = os.path.join(self.node_base_dir, "client-ca.crt")
admin_cfg = os.path.join(self.master_base_dir, "admin.kubeconfig")
oc_cmd_admin = "%s --config=%s" % ("oc", admin_cfg)
static_pod_logs_cmd = "master-logs"
# Note that a system can run both a master and a node.
# See "Master vs. node" above.
if self.is_master():
self.add_copy_spec([
self.master_cfg,
self.master_env,
os.path.join(self.master_base_dir, "*.crt"),
])
if self.is_static_pod_compatible():
self.add_copy_spec(os.path.join(self.static_pod_dir, "*.yaml"))
self.add_cmd_output([
"%s api api" % static_pod_logs_cmd,
"%s controllers controllers" % static_pod_logs_cmd,
])
# TODO: some thoughts about information that might also be useful
# to collect. However, these are maybe not needed in general
# and/or present some challenges (scale, sensitive, ...) and need
# some more thought. For now just leaving this comment here until
# we decide if it's worth collecting:
#
# General project status:
# oc status --all-namespaces (introduced in OSE 3.2)
# -> deemed as not worthy in BZ#1394527
# Metrics deployment configurations
# oc get -o json dc -n openshift-infra
# Logging stack deployment configurations
# oc get -o json dc -n logging
#
# Note: Information about nodes, events, pods, and services
# is already collected by the Kubernetes plugin
subcmds = [
"describe projects",
"adm top images",
"adm top imagestreams"
]
self.add_cmd_output([
'%s %s' % (oc_cmd_admin, subcmd) for subcmd in subcmds
])
jcmds = [
"hostsubnet",
"clusternetwork",
"netnamespaces"
]
self.add_cmd_output([
'%s get -o json %s' % (oc_cmd_admin, jcmd) for jcmd in jcmds
])
if self.get_option('all-namespaces'):
ocn = self.exec_cmd('%s get namespaces' % oc_cmd_admin)
ns_output = ocn['output'].splitlines()[1:]
nmsps = [n.split()[0] for n in ns_output if n]
else:
nmsps = [
'default',
'openshift-web-console',
'openshift-ansible-service-broker'
]
self.add_cmd_output([
'%s get -o json dc -n %s' % (oc_cmd_admin, n) for n in nmsps
])
if self.get_option('diag'):
diag_cmd = "%s adm diagnostics -l 0" % oc_cmd_admin
if self.get_option('diag-prevent'):
diag_cmd += " --prevent-modification=true"
self.add_cmd_output(diag_cmd)
self.add_journal(units=["atomic-openshift-master",
"atomic-openshift-master-api",
"atomic-openshift-master-controllers"])
# get logs from the infrastruture pods running in the default ns
pods = self.exec_cmd("%s get pod -o name -n default"
% oc_cmd_admin)
for pod in pods['output'].splitlines():
self.add_cmd_output("%s logs -n default %s"
% (oc_cmd_admin, pod))
# Note that a system can run both a master and a node.
# See "Master vs. node" above.
if self.is_node():
self.add_copy_spec([
self.node_cfg,
self.node_kubeconfig,
node_certs,
node_client_ca,
bstrap_node_cfg,
bstrap_kubeconfig,
os.path.join(self.node_base_dir, "*.crt"),
os.path.join(self.node_base_dir, "resolv.conf"),
os.path.join(self.node_base_dir, "node-dnsmasq.conf"),
])
self.add_journal(units="atomic-openshift-node")
if self.is_static_etcd():
self.add_cmd_output("%s etcd etcd" % static_pod_logs_cmd)
def postproc(self):
# Clear env values from objects that can contain sensitive data
# Sample JSON content:
# {
# "name": "MYSQL_PASSWORD",
# "value": "mypassword"
# },
# This will mask values when the "name" looks susceptible of
# values worth obfuscating, i.e. if the name contains strings
# like "pass", "pwd", "key" or "token".
env_regexp = r'(?P<var>{\s*"name":\s*[^,]*' \
r'(pass|pwd|key|token|cred|secret' \
r'|PASS|PWD|KEY|TOKEN|CRED|SECRET)[^,]*,' \
r'\s*"value":)[^}]*'
self.do_cmd_output_sub('oc*json', env_regexp, r'\g<var> "********"')
# LDAP identity provider
self.do_file_sub(self.master_cfg,
r"(bindPassword:\s*)(.*)",
r'\1"********"')
# github/google/OpenID identity providers
self.do_file_sub(self.master_cfg,
r"(clientSecret:\s*)(.*)",
r'\1"********"')
class AtomicOpenShift(OpenShiftOrigin, RedHatPlugin):
short_desc = 'OpenShift Enterprise / OpenShift Container Platform'
packages = ('atomic-openshift',)
# vim: set et ts=4 sw=4 :
| {
"pile_set_name": "Github"
} |
// Copyright 2018 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package auditconfigupdater_test
import (
"reflect"
"sync"
"github.com/juju/collections/set"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/worker/v2"
"github.com/juju/worker/v2/workertest"
gc "gopkg.in/check.v1"
apitesting "github.com/juju/juju/apiserver/testing"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/auditlog"
"github.com/juju/juju/state"
"github.com/juju/juju/state/watcher/watchertest"
jujutesting "github.com/juju/juju/testing"
"github.com/juju/juju/worker/auditconfigupdater"
)
type updaterSuite struct {
jujutesting.BaseSuite
}
var _ = gc.Suite(&updaterSuite{})
var ding = struct{}{}
func (s *updaterSuite) TestWorker(c *gc.C) {
configChanged := make(chan struct{}, 1)
initial := auditlog.Config{
Enabled: false,
}
source := configSource{
watcher: watchertest.NewNotifyWatcher(configChanged),
cfg: makeControllerConfig(false, false),
}
fakeTarget := apitesting.FakeAuditLog{}
var calls []auditlog.Config
factory := func(cfg auditlog.Config) auditlog.AuditLog {
calls = append(calls, cfg)
return &fakeTarget
}
w, err := auditconfigupdater.New(&source, initial, factory)
c.Assert(err, jc.ErrorIsNil)
defer workertest.CleanKill(c, w)
source.setConfig(makeControllerConfig(true, false))
configChanged <- ding
newConfig := waitForConfig(c, w, func(cfg auditlog.Config) bool {
return cfg.Enabled
})
c.Assert(newConfig.Enabled, gc.Equals, true)
c.Assert(newConfig.CaptureAPIArgs, gc.Equals, false)
c.Assert(newConfig.ExcludeMethods, gc.DeepEquals, set.NewStrings())
c.Assert(newConfig.Target, gc.Equals, auditlog.AuditLog(&fakeTarget))
c.Assert(calls, gc.HasLen, 1)
}
func waitForConfig(c *gc.C, w worker.Worker, predicate func(auditlog.Config) bool) auditlog.Config {
for a := jujutesting.LongAttempt.Start(); a.Next(); {
config := getWorkerConfig(c, w)
if predicate(config) {
return config
}
}
c.Fatalf("timed out waiting for matching config")
return auditlog.Config{}
}
func (s *updaterSuite) TestKeepsLogFileWhenAuditingDisabled(c *gc.C) {
configChanged := make(chan struct{}, 1)
initial := auditlog.Config{
Enabled: true,
Target: &apitesting.FakeAuditLog{},
}
source := configSource{
watcher: watchertest.NewNotifyWatcher(configChanged),
cfg: makeControllerConfig(true, false),
}
// Passing a nil factory means we can be sure it didn't try to
// create a new logfile.
w, err := auditconfigupdater.New(&source, initial, nil)
c.Assert(err, jc.ErrorIsNil)
defer workertest.CleanKill(c, w)
source.setConfig(makeControllerConfig(false, false))
configChanged <- ding
newConfig := waitForConfig(c, w, func(cfg auditlog.Config) bool {
return !cfg.Enabled
})
c.Assert(newConfig.Enabled, gc.Equals, false)
c.Assert(newConfig.Target, gc.Equals, initial.Target)
}
func (s *updaterSuite) TestKeepsLogFileWhenEnabled(c *gc.C) {
configChanged := make(chan struct{}, 1)
initial := auditlog.Config{
Enabled: false,
Target: &apitesting.FakeAuditLog{},
}
source := configSource{
watcher: watchertest.NewNotifyWatcher(configChanged),
cfg: makeControllerConfig(false, false),
}
// Passing a nil factory means we can be sure it didn't try to
// create a new logfile.
w, err := auditconfigupdater.New(&source, initial, nil)
c.Assert(err, jc.ErrorIsNil)
defer workertest.CleanKill(c, w)
source.setConfig(makeControllerConfig(true, false))
configChanged <- ding
newConfig := waitForConfig(c, w, func(cfg auditlog.Config) bool {
return cfg.Enabled
})
c.Assert(newConfig.Enabled, gc.Equals, true)
c.Assert(newConfig.Target, gc.Equals, initial.Target)
}
func (s *updaterSuite) TestChangingExcludeMethod(c *gc.C) {
configChanged := make(chan struct{}, 1)
initial := auditlog.Config{
Enabled: true,
ExcludeMethods: set.NewStrings("Pink.Floyd"),
Target: &apitesting.FakeAuditLog{},
}
source := configSource{
watcher: watchertest.NewNotifyWatcher(configChanged),
cfg: makeControllerConfig(true, false, "Pink.Floyd"),
}
w, err := auditconfigupdater.New(&source, initial, nil)
c.Assert(err, jc.ErrorIsNil)
defer workertest.CleanKill(c, w)
source.setConfig(makeControllerConfig(true, false, "Pink.Floyd", "Led.Zeppelin"))
configChanged <- ding
waitForConfig(c, w, func(cfg auditlog.Config) bool {
return reflect.DeepEqual(cfg.ExcludeMethods, set.NewStrings("Pink.Floyd", "Led.Zeppelin"))
})
source.setConfig(makeControllerConfig(true, false, "Led.Zeppelin"))
configChanged <- ding
waitForConfig(c, w, func(cfg auditlog.Config) bool {
return reflect.DeepEqual(cfg.ExcludeMethods, set.NewStrings("Led.Zeppelin"))
})
}
func (s *updaterSuite) TestChangingCaptureArgs(c *gc.C) {
configChanged := make(chan struct{}, 1)
initial := auditlog.Config{
Enabled: true,
CaptureAPIArgs: false,
Target: &apitesting.FakeAuditLog{},
}
source := configSource{
watcher: watchertest.NewNotifyWatcher(configChanged),
cfg: makeControllerConfig(true, false, "Pink.Floyd"),
}
w, err := auditconfigupdater.New(&source, initial, nil)
c.Assert(err, jc.ErrorIsNil)
defer workertest.CleanKill(c, w)
source.setConfig(makeControllerConfig(true, true))
configChanged <- ding
waitForConfig(c, w, func(cfg auditlog.Config) bool {
return cfg.CaptureAPIArgs
})
}
func makeControllerConfig(auditEnabled bool, captureArgs bool, methods ...interface{}) controller.Config {
result := map[string]interface{}{
"other-setting": "something",
"auditing-enabled": auditEnabled,
"audit-log-capture-args": captureArgs,
"audit-log-exclude-methods": methods,
}
return result
}
func getWorkerConfig(c *gc.C, w worker.Worker) auditlog.Config {
getter, ok := w.(interface {
CurrentConfig() auditlog.Config
})
if !ok {
c.Fatalf("worker %T doesn't expose CurrentConfig()", w)
}
return getter.CurrentConfig()
}
type configSource struct {
mu sync.Mutex
stub testing.Stub
watcher *watchertest.NotifyWatcher
cfg controller.Config
}
func (s *configSource) WatchControllerConfig() state.NotifyWatcher {
s.stub.AddCall("WatchControllerConfig")
return s.watcher
}
func (s *configSource) ControllerConfig() (controller.Config, error) {
s.mu.Lock()
defer s.mu.Unlock()
s.stub.AddCall("ControllerConfig")
if err := s.stub.NextErr(); err != nil {
return nil, err
}
return s.cfg, nil
}
func (s *configSource) setConfig(cfg controller.Config) {
s.mu.Lock()
defer s.mu.Unlock()
s.cfg = cfg
}
| {
"pile_set_name": "Github"
} |
interface BinaryTuple<T, S> {
first: T
second: S
}
interface Sequence<T> {
hasNext(): boolean
pop(): T
zip<S>(seq: Sequence<S>): Sequence<BinaryTuple<T, S>>
}
// error, despite the fact that the code explicitly says List<T> extends Sequence<T>, the current rules for infinitely expanding type references
// perform nominal subtyping checks that allow variance for type arguments, but not nominal subtyping for the generic type itself
interface List<T> extends Sequence<T> {
getLength(): number
zip<S>(seq: Sequence<S>): List<BinaryTuple<T, S>>
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_35) on Tue Oct 16 22:49:41 ICT 2012 -->
<TITLE>
ElementMapping (Apache FOP 1.1 API)
</TITLE>
<META NAME="date" CONTENT="2012-10-16">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ElementMapping (Apache FOP 1.1 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ElementMapping.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
fop 1.1</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../org/apache/fop/fo/DelegatingFOEventHandler.html" title="class in org.apache.fop.fo"><B>PREV CLASS</B></A>
<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/fop/fo/ElementMapping.html" target="_top"><B>FRAMES</B></A>
<A HREF="ElementMapping.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.fop.fo</FONT>
<BR>
Class ElementMapping</H2>
<PRE>
java.lang.Object
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.fop.fo.ElementMapping</B>
</PRE>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../org/apache/fop/render/afp/extensions/AFPElementMapping.html" title="class in org.apache.fop.render.afp.extensions">AFPElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.html" title="class in org.apache.fop.fo.extensions.svg">BatikExtensionElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/ExtensionElementMapping.html" title="class in org.apache.fop.fo.extensions">ExtensionElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/FOElementMapping.html" title="class in org.apache.fop.fo">FOElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/InternalElementMapping.html" title="class in org.apache.fop.fo.extensions">InternalElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/OldExtensionElementMapping.html" title="class in org.apache.fop.fo.extensions">OldExtensionElementMapping</A>, <A HREF="../../../../org/apache/fop/render/pcl/extensions/PCLElementMapping.html" title="class in org.apache.fop.render.pcl.extensions">PCLElementMapping</A>, <A HREF="../../../../org/apache/fop/render/pdf/extensions/PDFElementMapping.html" title="class in org.apache.fop.render.pdf.extensions">PDFElementMapping</A>, <A HREF="../../../../org/apache/fop/render/ps/extensions/PSExtensionElementMapping.html" title="class in org.apache.fop.render.ps.extensions">PSExtensionElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/xmp/RDFElementMapping.html" title="class in org.apache.fop.fo.extensions.xmp">RDFElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/svg/SVGElementMapping.html" title="class in org.apache.fop.fo.extensions.svg">SVGElementMapping</A>, <A HREF="../../../../org/apache/fop/fo/extensions/xmp/XMPElementMapping.html" title="class in org.apache.fop.fo.extensions.xmp">XMPElementMapping</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public abstract class <B>ElementMapping</B><DT>extends java.lang.Object</DL>
</PRE>
<P>
Abstract base class for Element Mappings (including FO Element Mappings)
which provide the framework of valid elements and attributes for a given
namespace.
<P>
<P>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
<A NAME="nested_class_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Nested Class Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo">ElementMapping.Maker</A></B></CODE>
<BR>
Base class for all Makers.</TD>
</TR>
</TABLE>
<!-- =========== FIELD SUMMARY =========== -->
<A NAME="field_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Field Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#DEFAULT">DEFAULT</A></B></CODE>
<BR>
constant for defining the default value</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected java.util.HashMap<java.lang.String,<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo">ElementMapping.Maker</A>></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#foObjs">foObjs</A></B></CODE>
<BR>
The HashMap table of formatting objects defined by the ElementMapping</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#namespaceURI">namespaceURI</A></B></CODE>
<BR>
The namespace for the ElementMapping</TD>
</TR>
</TABLE>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#ElementMapping()">ElementMapping</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static org.w3c.dom.DOMImplementation</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#getDefaultDOMImplementation()">getDefaultDOMImplementation</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> org.w3c.dom.DOMImplementation</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#getDOMImplementation()">getDOMImplementation</A></B>()</CODE>
<BR>
Returns the DOMImplementation used by this ElementMapping.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#getNamespaceURI()">getNamespaceURI</A></B>()</CODE>
<BR>
Returns the namespace URI for this element mapping</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#getStandardPrefix()">getStandardPrefix</A></B>()</CODE>
<BR>
</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> java.util.HashMap<java.lang.String,<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo">ElementMapping.Maker</A>></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#getTable()">getTable</A></B>()</CODE>
<BR>
Returns a HashMap of maker objects for this element mapping</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected abstract void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#initialize()">initialize</A></B>()</CODE>
<BR>
Initializes the set of maker objects associated with this ElementMapping</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/fop/fo/ElementMapping.html#isAttributeProperty(org.apache.xmlgraphics.util.QName)">isAttributeProperty</A></B>(org.apache.xmlgraphics.util.QName attributeName)</CODE>
<BR>
Indicates whether a particular attribute of the namespace is a property, i.e.</TD>
</TR>
</TABLE>
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<!-- ============ FIELD DETAIL =========== -->
<A NAME="field_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Field Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="DEFAULT"><!-- --></A><H3>
DEFAULT</H3>
<PRE>
public static final java.lang.String <B>DEFAULT</B></PRE>
<DL>
<DD>constant for defining the default value
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../../constant-values.html#org.apache.fop.fo.ElementMapping.DEFAULT">Constant Field Values</A></DL>
</DL>
<HR>
<A NAME="foObjs"><!-- --></A><H3>
foObjs</H3>
<PRE>
protected java.util.HashMap<java.lang.String,<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo">ElementMapping.Maker</A>> <B>foObjs</B></PRE>
<DL>
<DD>The HashMap table of formatting objects defined by the ElementMapping
<P>
<DL>
</DL>
</DL>
<HR>
<A NAME="namespaceURI"><!-- --></A><H3>
namespaceURI</H3>
<PRE>
protected java.lang.String <B>namespaceURI</B></PRE>
<DL>
<DD>The namespace for the ElementMapping
<P>
<DL>
</DL>
</DL>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="ElementMapping()"><!-- --></A><H3>
ElementMapping</H3>
<PRE>
public <B>ElementMapping</B>()</PRE>
<DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="getTable()"><!-- --></A><H3>
getTable</H3>
<PRE>
public java.util.HashMap<java.lang.String,<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo">ElementMapping.Maker</A>> <B>getTable</B>()</PRE>
<DL>
<DD>Returns a HashMap of maker objects for this element mapping
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Table of Maker objects for this ElementMapping</DL>
</DD>
</DL>
<HR>
<A NAME="getNamespaceURI()"><!-- --></A><H3>
getNamespaceURI</H3>
<PRE>
public java.lang.String <B>getNamespaceURI</B>()</PRE>
<DL>
<DD>Returns the namespace URI for this element mapping
<P>
<DD><DL>
<DT><B>Returns:</B><DD>Namespace URI for this element mapping</DL>
</DD>
</DL>
<HR>
<A NAME="getDOMImplementation()"><!-- --></A><H3>
getDOMImplementation</H3>
<PRE>
public org.w3c.dom.DOMImplementation <B>getDOMImplementation</B>()</PRE>
<DL>
<DD>Returns the DOMImplementation used by this ElementMapping. The value returned may be null
for cases where no DOM is used to represent the element tree (XSL-FO, for example). This
method is used by the intermediate format to instantiate the right kind of DOM document
for foreign objects. For example, SVG handled through Apache Batik has to use a special
DOMImplementation.
<P>
<DD><DL>
<DT><B>Returns:</B><DD>the DOMImplementation used by this ElementMapping, may be null</DL>
</DD>
</DL>
<HR>
<A NAME="getDefaultDOMImplementation()"><!-- --></A><H3>
getDefaultDOMImplementation</H3>
<PRE>
public static org.w3c.dom.DOMImplementation <B>getDefaultDOMImplementation</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>the default DOMImplementation when no specialized DOM is necessary.</DL>
</DD>
</DL>
<HR>
<A NAME="getStandardPrefix()"><!-- --></A><H3>
getStandardPrefix</H3>
<PRE>
public java.lang.String <B>getStandardPrefix</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>the standard namespace prefix for this namespace or null if it is not known.</DL>
</DD>
</DL>
<HR>
<A NAME="isAttributeProperty(org.apache.xmlgraphics.util.QName)"><!-- --></A><H3>
isAttributeProperty</H3>
<PRE>
public boolean <B>isAttributeProperty</B>(org.apache.xmlgraphics.util.QName attributeName)</PRE>
<DL>
<DD>Indicates whether a particular attribute of the namespace is a property, i.e. the attribute
value should be converted to a property value.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>attributeName</CODE> - the attribute name
<DT><B>Returns:</B><DD>true if the attribute should be converted to a property</DL>
</DD>
</DL>
<HR>
<A NAME="initialize()"><!-- --></A><H3>
initialize</H3>
<PRE>
protected abstract void <B>initialize</B>()</PRE>
<DL>
<DD>Initializes the set of maker objects associated with this ElementMapping
<P>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ElementMapping.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
fop 1.1</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../org/apache/fop/fo/DelegatingFOEventHandler.html" title="class in org.apache.fop.fo"><B>PREV CLASS</B></A>
<A HREF="../../../../org/apache/fop/fo/ElementMapping.Maker.html" title="class in org.apache.fop.fo"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/fop/fo/ElementMapping.html" target="_top"><B>FRAMES</B></A>
<A HREF="ElementMapping.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright 1999-2012 The Apache Software Foundation. All Rights Reserved.
</BODY>
</HTML>
| {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_79) on Mon Jun 29 06:45:50 CEST 2015 -->
<title>SelectorContainer (Apache Ant API)</title>
<meta name="date" content="2015-06-29">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="SelectorContainer (Apache Ant API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/tools/ant/types/selectors/ReadableSelector.html" title="class in org.apache.tools.ant.types.selectors"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorScanner.html" title="interface in org.apache.tools.ant.types.selectors"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/tools/ant/types/selectors/SelectorContainer.html" target="_top">Frames</a></li>
<li><a href="SelectorContainer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.tools.ant.types.selectors</div>
<h2 title="Interface SelectorContainer" class="title">Interface SelectorContainer</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../../../org/apache/tools/ant/types/AbstractFileSet.html" title="class in org.apache.tools.ant.types">AbstractFileSet</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/AbstractSelectorContainer.html" title="class in org.apache.tools.ant.types.selectors">AbstractSelectorContainer</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/AndSelector.html" title="class in org.apache.tools.ant.types.selectors">AndSelector</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Apt.html" title="class in org.apache.tools.ant.taskdefs">Apt</a>, <a href="../../../../../../org/apache/tools/ant/types/ArchiveFileSet.html" title="class in org.apache.tools.ant.types">ArchiveFileSet</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/BaseSelectorContainer.html" title="class in org.apache.tools.ant.types.selectors">BaseSelectorContainer</a>, <a href="../../../../../../org/apache/tools/ant/types/resources/BCFileSet.html" title="class in org.apache.tools.ant.types.resources">BCFileSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/Cab.html" title="class in org.apache.tools.ant.taskdefs.optional">Cab</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Checksum.html" title="class in org.apache.tools.ant.taskdefs">Checksum</a>, <a href="../../../../../../org/apache/tools/ant/types/optional/depend/ClassfileSet.html" title="class in org.apache.tools.ant.types.optional.depend">ClassfileSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Copydir.html" title="class in org.apache.tools.ant.taskdefs">Copydir</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Delete.html" title="class in org.apache.tools.ant.taskdefs">Delete</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/depend/Depend.html" title="class in org.apache.tools.ant.taskdefs.optional.depend">Depend</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/DependSet.html" title="class in org.apache.tools.ant.taskdefs">DependSet</a>, <a href="../../../../../../org/apache/tools/ant/types/DirSet.html" title="class in org.apache.tools.ant.types">DirSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Ear.html" title="class in org.apache.tools.ant.taskdefs">Ear</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.html" title="class in org.apache.tools.ant.taskdefs.optional.ejb">EjbJar</a>, <a href="../../../../../../org/apache/tools/ant/types/resources/Files.html" title="class in org.apache.tools.ant.types.resources">Files</a>, <a href="../../../../../../org/apache/tools/ant/types/FileSet.html" title="class in org.apache.tools.ant.types">FileSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/FixCRLF.html" title="class in org.apache.tools.ant.taskdefs">FixCRLF</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/image/Image.html" title="class in org.apache.tools.ant.taskdefs.optional.image">Image</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/condition/IsFileSelected.html" title="class in org.apache.tools.ant.taskdefs.condition">IsFileSelected</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Jar.html" title="class in org.apache.tools.ant.taskdefs">Jar</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Javac.html" title="class in org.apache.tools.ant.taskdefs">Javac</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Javadoc.TagArgument.html" title="class in org.apache.tools.ant.taskdefs">Javadoc.TagArgument</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/jlink/JlinkTask.html" title="class in org.apache.tools.ant.taskdefs.optional.jlink">JlinkTask</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/jsp/JspC.html" title="class in org.apache.tools.ant.taskdefs.optional.jsp">JspC</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/extension/LibFileSet.html" title="class in org.apache.tools.ant.taskdefs.optional.extension">LibFileSet</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/MajoritySelector.html" title="class in org.apache.tools.ant.types.selectors">MajoritySelector</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/MatchingTask.html" title="class in org.apache.tools.ant.taskdefs">MatchingTask</a>, <a href="../../../../../../org/apache/tools/ant/types/resources/MultiRootFileSet.html" title="class in org.apache.tools.ant.types.resources">MultiRootFileSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/Native2Ascii.html" title="class in org.apache.tools.ant.taskdefs.optional">Native2Ascii</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/NetRexxC.html" title="class in org.apache.tools.ant.taskdefs.optional">NetRexxC</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/NoneSelector.html" title="class in org.apache.tools.ant.types.selectors">NoneSelector</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/NotSelector.html" title="class in org.apache.tools.ant.types.selectors">NotSelector</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/OrSelector.html" title="class in org.apache.tools.ant.types.selectors">OrSelector</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/RenameExtensions.html" title="class in org.apache.tools.ant.taskdefs.optional">RenameExtensions</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Replace.html" title="class in org.apache.tools.ant.taskdefs">Replace</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Rmic.html" title="class in org.apache.tools.ant.taskdefs">Rmic</a>, <a href="../../../../../../org/apache/tools/ant/types/selectors/SelectSelector.html" title="class in org.apache.tools.ant.types.selectors">SelectSelector</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Sync.SyncTarget.html" title="class in org.apache.tools.ant.taskdefs">Sync.SyncTarget</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Tar.html" title="class in org.apache.tools.ant.taskdefs">Tar</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Tar.TarFileSet.html" title="class in org.apache.tools.ant.taskdefs">Tar.TarFileSet</a>, <a href="../../../../../../org/apache/tools/ant/types/TarFileSet.html" title="class in org.apache.tools.ant.types">TarFileSet</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/i18n/Translate.html" title="class in org.apache.tools.ant.taskdefs.optional.i18n">Translate</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/War.html" title="class in org.apache.tools.ant.taskdefs">War</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.html" title="class in org.apache.tools.ant.taskdefs.optional.jsp">WLJspc</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/XSLTProcess.html" title="class in org.apache.tools.ant.taskdefs">XSLTProcess</a>, <a href="../../../../../../org/apache/tools/ant/taskdefs/Zip.html" title="class in org.apache.tools.ant.taskdefs">Zip</a>, <a href="../../../../../../org/apache/tools/ant/types/ZipFileSet.html" title="class in org.apache.tools.ant.types">ZipFileSet</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="strong">SelectorContainer</span></pre>
<div class="block">This is the interface for selectors that can contain other selectors.</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>1.5</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#add(org.apache.tools.ant.types.selectors.FileSelector)">add</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a> selector)</code>
<div class="block">add an arbitrary selector</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addAnd(org.apache.tools.ant.types.selectors.AndSelector)">addAnd</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/AndSelector.html" title="class in org.apache.tools.ant.types.selectors">AndSelector</a> selector)</code>
<div class="block">add an "And" selector entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addContains(org.apache.tools.ant.types.selectors.ContainsSelector)">addContains</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/ContainsSelector.html" title="class in org.apache.tools.ant.types.selectors">ContainsSelector</a> selector)</code>
<div class="block">add a contains selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addContainsRegexp(org.apache.tools.ant.types.selectors.ContainsRegexpSelector)">addContainsRegexp</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/ContainsRegexpSelector.html" title="class in org.apache.tools.ant.types.selectors">ContainsRegexpSelector</a> selector)</code>
<div class="block">add a regular expression selector entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addCustom(org.apache.tools.ant.types.selectors.ExtendSelector)">addCustom</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/ExtendSelector.html" title="class in org.apache.tools.ant.types.selectors">ExtendSelector</a> selector)</code>
<div class="block">add an extended selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addDate(org.apache.tools.ant.types.selectors.DateSelector)">addDate</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/DateSelector.html" title="class in org.apache.tools.ant.types.selectors">DateSelector</a> selector)</code>
<div class="block">add a selector date entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addDepend(org.apache.tools.ant.types.selectors.DependSelector)">addDepend</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/DependSelector.html" title="class in org.apache.tools.ant.types.selectors">DependSelector</a> selector)</code>
<div class="block">add a depends selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addDepth(org.apache.tools.ant.types.selectors.DepthSelector)">addDepth</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/DepthSelector.html" title="class in org.apache.tools.ant.types.selectors">DepthSelector</a> selector)</code>
<div class="block">add a depth selector entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addDifferent(org.apache.tools.ant.types.selectors.DifferentSelector)">addDifferent</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/DifferentSelector.html" title="class in org.apache.tools.ant.types.selectors">DifferentSelector</a> selector)</code>
<div class="block">add the different selector</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addFilename(org.apache.tools.ant.types.selectors.FilenameSelector)">addFilename</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/FilenameSelector.html" title="class in org.apache.tools.ant.types.selectors">FilenameSelector</a> selector)</code>
<div class="block">add a selector filename entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addMajority(org.apache.tools.ant.types.selectors.MajoritySelector)">addMajority</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/MajoritySelector.html" title="class in org.apache.tools.ant.types.selectors">MajoritySelector</a> selector)</code>
<div class="block">add a majority selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addModified(org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector)">addModified</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.html" title="class in org.apache.tools.ant.types.selectors.modifiedselector">ModifiedSelector</a> selector)</code>
<div class="block">add the modified selector</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addNone(org.apache.tools.ant.types.selectors.NoneSelector)">addNone</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/NoneSelector.html" title="class in org.apache.tools.ant.types.selectors">NoneSelector</a> selector)</code>
<div class="block">add a "None" selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addNot(org.apache.tools.ant.types.selectors.NotSelector)">addNot</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/NotSelector.html" title="class in org.apache.tools.ant.types.selectors">NotSelector</a> selector)</code>
<div class="block">add a "Not" selector entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addOr(org.apache.tools.ant.types.selectors.OrSelector)">addOr</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/OrSelector.html" title="class in org.apache.tools.ant.types.selectors">OrSelector</a> selector)</code>
<div class="block">add an "Or" selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addPresent(org.apache.tools.ant.types.selectors.PresentSelector)">addPresent</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/PresentSelector.html" title="class in org.apache.tools.ant.types.selectors">PresentSelector</a> selector)</code>
<div class="block">add a present selector entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addSelector(org.apache.tools.ant.types.selectors.SelectSelector)">addSelector</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/SelectSelector.html" title="class in org.apache.tools.ant.types.selectors">SelectSelector</a> selector)</code>
<div class="block">add a "Select" selector entry on the selector list</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addSize(org.apache.tools.ant.types.selectors.SizeSelector)">addSize</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/SizeSelector.html" title="class in org.apache.tools.ant.types.selectors">SizeSelector</a> selector)</code>
<div class="block">add a selector size entry on the selector list</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#addType(org.apache.tools.ant.types.selectors.TypeSelector)">addType</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/TypeSelector.html" title="class in org.apache.tools.ant.types.selectors">TypeSelector</a> selector)</code>
<div class="block">add the type selector</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#appendSelector(org.apache.tools.ant.types.selectors.FileSelector)">appendSelector</a></strong>(<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a> selector)</code>
<div class="block">Add a new selector into this container.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a>[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#getSelectors(org.apache.tools.ant.Project)">getSelectors</a></strong>(<a href="../../../../../../org/apache/tools/ant/Project.html" title="class in org.apache.tools.ant">Project</a> p)</code>
<div class="block">Returns the set of selectors as an array.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#hasSelectors()">hasSelectors</a></strong>()</code>
<div class="block">Indicates whether there are any selectors here.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#selectorCount()">selectorCount</a></strong>()</code>
<div class="block">Gives the count of the number of selectors in this container</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>java.util.Enumeration<<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a>></code></td>
<td class="colLast"><code><strong><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorContainer.html#selectorElements()">selectorElements</a></strong>()</code>
<div class="block">Returns an enumerator for accessing the set of selectors.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="hasSelectors()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hasSelectors</h4>
<pre>boolean hasSelectors()</pre>
<div class="block">Indicates whether there are any selectors here.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>whether any selectors are in this container</dd></dl>
</li>
</ul>
<a name="selectorCount()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>selectorCount</h4>
<pre>int selectorCount()</pre>
<div class="block">Gives the count of the number of selectors in this container</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the number of selectors in this container</dd></dl>
</li>
</ul>
<a name="getSelectors(org.apache.tools.ant.Project)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSelectors</h4>
<pre><a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a>[] getSelectors(<a href="../../../../../../org/apache/tools/ant/Project.html" title="class in org.apache.tools.ant">Project</a> p)</pre>
<div class="block">Returns the set of selectors as an array.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>p</code> - the current project</dd>
<dt><span class="strong">Returns:</span></dt><dd>an array of selectors in this container</dd></dl>
</li>
</ul>
<a name="selectorElements()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>selectorElements</h4>
<pre>java.util.Enumeration<<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a>> selectorElements()</pre>
<div class="block">Returns an enumerator for accessing the set of selectors.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>an enumerator that goes through each of the selectors</dd></dl>
</li>
</ul>
<a name="appendSelector(org.apache.tools.ant.types.selectors.FileSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>appendSelector</h4>
<pre>void appendSelector(<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a> selector)</pre>
<div class="block">Add a new selector into this container.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the new selector to add</dd></dl>
</li>
</ul>
<a name="addSelector(org.apache.tools.ant.types.selectors.SelectSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addSelector</h4>
<pre>void addSelector(<a href="../../../../../../org/apache/tools/ant/types/selectors/SelectSelector.html" title="class in org.apache.tools.ant.types.selectors">SelectSelector</a> selector)</pre>
<div class="block">add a "Select" selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addAnd(org.apache.tools.ant.types.selectors.AndSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addAnd</h4>
<pre>void addAnd(<a href="../../../../../../org/apache/tools/ant/types/selectors/AndSelector.html" title="class in org.apache.tools.ant.types.selectors">AndSelector</a> selector)</pre>
<div class="block">add an "And" selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addOr(org.apache.tools.ant.types.selectors.OrSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addOr</h4>
<pre>void addOr(<a href="../../../../../../org/apache/tools/ant/types/selectors/OrSelector.html" title="class in org.apache.tools.ant.types.selectors">OrSelector</a> selector)</pre>
<div class="block">add an "Or" selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addNot(org.apache.tools.ant.types.selectors.NotSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addNot</h4>
<pre>void addNot(<a href="../../../../../../org/apache/tools/ant/types/selectors/NotSelector.html" title="class in org.apache.tools.ant.types.selectors">NotSelector</a> selector)</pre>
<div class="block">add a "Not" selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addNone(org.apache.tools.ant.types.selectors.NoneSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addNone</h4>
<pre>void addNone(<a href="../../../../../../org/apache/tools/ant/types/selectors/NoneSelector.html" title="class in org.apache.tools.ant.types.selectors">NoneSelector</a> selector)</pre>
<div class="block">add a "None" selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addMajority(org.apache.tools.ant.types.selectors.MajoritySelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addMajority</h4>
<pre>void addMajority(<a href="../../../../../../org/apache/tools/ant/types/selectors/MajoritySelector.html" title="class in org.apache.tools.ant.types.selectors">MajoritySelector</a> selector)</pre>
<div class="block">add a majority selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addDate(org.apache.tools.ant.types.selectors.DateSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addDate</h4>
<pre>void addDate(<a href="../../../../../../org/apache/tools/ant/types/selectors/DateSelector.html" title="class in org.apache.tools.ant.types.selectors">DateSelector</a> selector)</pre>
<div class="block">add a selector date entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addSize(org.apache.tools.ant.types.selectors.SizeSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addSize</h4>
<pre>void addSize(<a href="../../../../../../org/apache/tools/ant/types/selectors/SizeSelector.html" title="class in org.apache.tools.ant.types.selectors">SizeSelector</a> selector)</pre>
<div class="block">add a selector size entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addFilename(org.apache.tools.ant.types.selectors.FilenameSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addFilename</h4>
<pre>void addFilename(<a href="../../../../../../org/apache/tools/ant/types/selectors/FilenameSelector.html" title="class in org.apache.tools.ant.types.selectors">FilenameSelector</a> selector)</pre>
<div class="block">add a selector filename entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addCustom(org.apache.tools.ant.types.selectors.ExtendSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addCustom</h4>
<pre>void addCustom(<a href="../../../../../../org/apache/tools/ant/types/selectors/ExtendSelector.html" title="class in org.apache.tools.ant.types.selectors">ExtendSelector</a> selector)</pre>
<div class="block">add an extended selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addContains(org.apache.tools.ant.types.selectors.ContainsSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addContains</h4>
<pre>void addContains(<a href="../../../../../../org/apache/tools/ant/types/selectors/ContainsSelector.html" title="class in org.apache.tools.ant.types.selectors">ContainsSelector</a> selector)</pre>
<div class="block">add a contains selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addPresent(org.apache.tools.ant.types.selectors.PresentSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addPresent</h4>
<pre>void addPresent(<a href="../../../../../../org/apache/tools/ant/types/selectors/PresentSelector.html" title="class in org.apache.tools.ant.types.selectors">PresentSelector</a> selector)</pre>
<div class="block">add a present selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addDepth(org.apache.tools.ant.types.selectors.DepthSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addDepth</h4>
<pre>void addDepth(<a href="../../../../../../org/apache/tools/ant/types/selectors/DepthSelector.html" title="class in org.apache.tools.ant.types.selectors">DepthSelector</a> selector)</pre>
<div class="block">add a depth selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addDepend(org.apache.tools.ant.types.selectors.DependSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addDepend</h4>
<pre>void addDepend(<a href="../../../../../../org/apache/tools/ant/types/selectors/DependSelector.html" title="class in org.apache.tools.ant.types.selectors">DependSelector</a> selector)</pre>
<div class="block">add a depends selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addContainsRegexp(org.apache.tools.ant.types.selectors.ContainsRegexpSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addContainsRegexp</h4>
<pre>void addContainsRegexp(<a href="../../../../../../org/apache/tools/ant/types/selectors/ContainsRegexpSelector.html" title="class in org.apache.tools.ant.types.selectors">ContainsRegexpSelector</a> selector)</pre>
<div class="block">add a regular expression selector entry on the selector list</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd></dl>
</li>
</ul>
<a name="addType(org.apache.tools.ant.types.selectors.TypeSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addType</h4>
<pre>void addType(<a href="../../../../../../org/apache/tools/ant/types/selectors/TypeSelector.html" title="class in org.apache.tools.ant.types.selectors">TypeSelector</a> selector)</pre>
<div class="block">add the type selector</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd><dt><span class="strong">Since:</span></dt>
<dd>ant 1.6</dd></dl>
</li>
</ul>
<a name="addDifferent(org.apache.tools.ant.types.selectors.DifferentSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addDifferent</h4>
<pre>void addDifferent(<a href="../../../../../../org/apache/tools/ant/types/selectors/DifferentSelector.html" title="class in org.apache.tools.ant.types.selectors">DifferentSelector</a> selector)</pre>
<div class="block">add the different selector</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd><dt><span class="strong">Since:</span></dt>
<dd>ant 1.6</dd></dl>
</li>
</ul>
<a name="addModified(org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addModified</h4>
<pre>void addModified(<a href="../../../../../../org/apache/tools/ant/types/selectors/modifiedselector/ModifiedSelector.html" title="class in org.apache.tools.ant.types.selectors.modifiedselector">ModifiedSelector</a> selector)</pre>
<div class="block">add the modified selector</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd><dt><span class="strong">Since:</span></dt>
<dd>ant 1.6</dd></dl>
</li>
</ul>
<a name="add(org.apache.tools.ant.types.selectors.FileSelector)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>add</h4>
<pre>void add(<a href="../../../../../../org/apache/tools/ant/types/selectors/FileSelector.html" title="interface in org.apache.tools.ant.types.selectors">FileSelector</a> selector)</pre>
<div class="block">add an arbitrary selector</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>selector</code> - the selector to add</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.6</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../org/apache/tools/ant/types/selectors/ReadableSelector.html" title="class in org.apache.tools.ant.types.selectors"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../org/apache/tools/ant/types/selectors/SelectorScanner.html" title="interface in org.apache.tools.ant.types.selectors"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?org/apache/tools/ant/types/selectors/SelectorContainer.html" target="_top">Frames</a></li>
<li><a href="SelectorContainer.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| {
"pile_set_name": "Github"
} |
package mxh.kickassmenu.gestured.app;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import mxh.kickassmenu.gestured.SlidingMenu;
@SuppressWarnings("JavadocReference")
public class SlidingActivity extends Activity implements SlidingActivityBase {
private SlidingActivityHelper mHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHelper = new SlidingActivityHelper(this);
mHelper.onCreate(savedInstanceState);
}
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mHelper.onPostCreate(savedInstanceState);
}
@Override
public View findViewById(int id) {
View v = super.findViewById(id);
if (v != null)
return v;
return mHelper.findViewById(id);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mHelper.onSaveInstanceState(outState);
}
@Override
public void setContentView(int id) {
setContentView(getLayoutInflater().inflate(id, null));
}
@Override
public void setContentView(View v) {
setContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
@Override
public void setContentView(View v, LayoutParams params) {
super.setContentView(v, params);
mHelper.registerAboveContentView(v, params);
}
public void setBehindContentView(int id) {
setBehindContentView(getLayoutInflater().inflate(id, null));
}
public void setBehindContentView(View v) {
setBehindContentView(v, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#setBehindContentView(android.view.View, android.view.ViewGroup.LayoutParams)
*/
public void setBehindContentView(View v, LayoutParams params) {
mHelper.setBehindContentView(v, params);
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#getSlidingMenu()
*/
public SlidingMenu getSlidingMenu() {
return mHelper.getSlidingMenu();
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#toggle()
*/
public void toggle() {
mHelper.toggle();
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#showAbove()
*/
public void showContent() {
mHelper.showContent();
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#showBehind()
*/
public void showMenu() {
mHelper.showMenu();
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#showSecondaryMenu()
*/
public void showSecondaryMenu() {
mHelper.showSecondaryMenu();
}
/* (non-Javadoc)
* @see com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivityBase#setSlidingActionBarEnabled(boolean)
*/
public void setSlidingActionBarEnabled(boolean b) {
mHelper.setSlidingActionBarEnabled(b);
}
/* (non-Javadoc)
* @see android.app.Activity#onKeyUp(int, android.view.KeyEvent)
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
boolean b = mHelper.onKeyUp(keyCode, event);
if (b) return b;
return super.onKeyUp(keyCode, event);
}
}
| {
"pile_set_name": "Github"
} |
base=./mount
dir=$base/temp/ai2018/sentiment/tfrecords/$SRC
fold=0
if [ $# == 1 ];
then fold=$1
fi
if [ $FOLD ];
then fold=$FOLD
fi
model_dir=$base/temp/ai2018/sentiment/model/v1/$fold/$SRC/gru.char.sfu/
num_epochs=20
mkdir -p $model_dir/epoch
cp $dir/vocab* $model_dir
cp $dir/vocab* $model_dir/epoch
exe=./train.py
if [ "$INFER" = "1" ];
then echo "INFER MODE"
exe=./infer.py
model_dir=$1
fold=0
fi
if [ "$INFER" = "2" ];
then echo "VALID MODE"
exe=./infer.py
model_dir=$1
fold=0
fi
python $exe \
--use_char=1 \
--char_combiner=sfu \
--fold=$fold \
--use_label_att=0 \
--use_self_match=0 \
--vocab $dir/vocab.txt \
--model_dir=$model_dir \
--train_input=$dir/train/'*,' \
--test_input=$dir/test/'*,' \
--info_path=$dir/info.pkl \
--emb_dim 300 \
--batch_size 32 \
--encoder_type=rnn \
--keep_prob=0.7 \
--num_layers=1 \
--rnn_hidden_size=100 \
--encoder_output_method=max \
--eval_interval_steps 1000 \
--metric_eval_interval_steps 1000 \
--save_interval_steps 1000 \
--save_interval_epochs=1 \
--valid_interval_epochs=1 \
--inference_interval_epochs=1 \
--freeze_graph=1 \
--optimizer=adam \
--learning_rate=0.001 \
--decay_target=f1 \
--decay_patience=1 \
--decay_factor=0.8 \
--num_epochs=$num_epochs \
| {
"pile_set_name": "Github"
} |
"""A character from the Star Wars universe"""
interface Character {
"""The movies this character appears in"""
appearsIn: [Episode]!
"""The date character was born."""
birthDate: Date!
"""The date character was born."""
deathDate: Date!
"""The movie this character first appears in"""
firstAppearsIn: Episode!
"""The friends of the character, or an empty list if they have none"""
friends: [Character]
"""The friends of the character exposed as a connection with edges"""
friendsConnection(first: Int, after: ID): FriendsConnection!
"""The ID of the character"""
id: ID!
"""The name of the character"""
name: String!
}
"""The input object sent when passing in a color"""
input ColorInput {
red: Int!
green: Int!
blue: Int!
}
"""The `Date` scalar type represents date format."""
scalar Date
"""An autonomous mechanical character in the Star Wars universe"""
type Droid implements Character {
"""The movies this droid appears in"""
appearsIn: [Episode]!
"""The date droid was created."""
birthDate: Date!
"""The droid character was decomissioned."""
deathDate: Date!
"""The movie this character first appears in"""
firstAppearsIn: Episode!
"""This droid's friends, or an empty list if they have none"""
friends: [Character]
"""The friends of the droid exposed as a connection with edges"""
friendsConnection(first: Int, after: ID): FriendsConnection!
"""The ID of the droid"""
id: ID!
"""What others call this droid"""
name: String!
"""This droid's primary function"""
primaryFunction: String
}
"""The episodes in the Star Wars trilogy (with special symbol $S)"""
enum Episode {
"""
Star Wars Episode IV: A New Hope, released in 1977. (with special symbol $S)
"""
NEWHOPE
"""Star Wars Episode V: The Empire Strikes Back, released in 1980."""
EMPIRE
"""
Star Wars Episode VI: Return of the Jedi, released in 1983. (JEDI in lowercase)
"""
jedi
}
"""A connection object for a character's friends"""
type FriendsConnection {
"""The edges for each of the character's friends."""
edges: [FriendsEdge]
"""A list of the friends, as a convenience when edges are not needed."""
friends: [Character]
"""Information for paginating this connection"""
pageInfo: PageInfo!
"""The total number of friends"""
totalCount: Int
}
"""An edge object for a character's friends"""
type FriendsEdge {
"""A cursor used for pagination"""
cursor: ID!
"""The character represented by this friendship edge"""
node: Character
}
"""A humanoid creature from the Star Wars universe"""
type Human implements Character {
"""The movies this human appears in"""
appearsIn: [Episode]!
"""The date character was born."""
birthDate: Date!
"""The date character was born."""
deathDate: Date!
"""The movie this character first appears in"""
firstAppearsIn: Episode!
"""This human's friends, or an empty list if they have none"""
friends: [Character]
"""The friends of the human exposed as a connection with edges"""
friendsConnection(first: Int, after: ID): FriendsConnection!
"""Height in the preferred unit, default is meters"""
height(unit: LengthUnit = METER): Float
"""The home planet of the human, or null if unknown"""
homePlanet: String
"""The ID of the human"""
id: ID!
"""Mass in kilograms, or null if unknown"""
mass: Float
"""What this human calls themselves"""
name: String!
"""A list of starships this person has piloted, or an empty list if none"""
starships: [Starship]
}
"""Units of height"""
enum LengthUnit {
"""The standard unit around the world"""
METER
"""Primarily used in the United States"""
FOOT
}
"""The mutation type, represents all updates we can make to our data"""
type Mutation {
createReview(episode: Episode, review: ReviewInput!): Review
}
"""Information for paginating this connection"""
type PageInfo {
endCursor: ID
hasNextPage: Boolean!
startCursor: ID
}
"""
The query type, represents all of the entry points into our object graph
"""
type Query {
character(id: ID!): Character
droid(id: ID!): Droid
hero(episode: Episode): Character
human(id: ID!): Human
reviews(episode: Episode!): [Review]
search(text: String): [SearchResult]
starship(id: ID!): Starship
}
"""Represents a review for a movie"""
type Review {
"""Comment about the movie"""
commentary: String
"""The number of stars this review gave, 1-5"""
stars: Int!
}
"""The input object sent when someone is creating a new review"""
input ReviewInput {
"""0-5 stars"""
stars: Int!
"""Comment about the movie, optional"""
commentary: String
"""Favorite color, optional"""
favoriteColor: ColorInput
}
union SearchResult = Human | Droid | Starship
type Starship {
coordinates: [[Float!]!]
"""The ID of the starship"""
id: ID!
"""Length of the starship, along the longest axis"""
length(unit: LengthUnit = METER): Float
"""The name of the starship"""
name: String!
}
| {
"pile_set_name": "Github"
} |
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var key = { toString: function() { return 'baz'; } }
var object = { baz: 42 };
assertEquals(42, object[key]);
object[key] = 87;
assertEquals(87, object[key]);
object[key]++;
assertEquals(88, object[key]);
| {
"pile_set_name": "Github"
} |
// SPDX-License-Identifier: GPL-2.0-only
/*
* Battery class driver for Apple PMU
*
* Copyright © 2006 David Woodhouse <[email protected]>
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/power_supply.h>
#include <linux/adb.h>
#include <linux/pmu.h>
#include <linux/slab.h>
static struct pmu_battery_dev {
struct power_supply *bat;
struct power_supply_desc bat_desc;
struct pmu_battery_info *pbi;
char name[16];
int propval;
} *pbats[PMU_MAX_BATTERIES];
#define to_pmu_battery_dev(x) power_supply_get_drvdata(x)
/*********************************************************************
* Power
*********************************************************************/
static int pmu_get_ac_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
val->intval = (!!(pmu_power_flags & PMU_PWR_AC_PRESENT)) ||
(pmu_battery_count == 0);
break;
default:
return -EINVAL;
}
return 0;
}
static enum power_supply_property pmu_ac_props[] = {
POWER_SUPPLY_PROP_ONLINE,
};
static const struct power_supply_desc pmu_ac_desc = {
.name = "pmu-ac",
.type = POWER_SUPPLY_TYPE_MAINS,
.properties = pmu_ac_props,
.num_properties = ARRAY_SIZE(pmu_ac_props),
.get_property = pmu_get_ac_prop,
};
static struct power_supply *pmu_ac;
/*********************************************************************
* Battery properties
*********************************************************************/
static char *pmu_batt_types[] = {
"Smart", "Comet", "Hooper", "Unknown"
};
static char *pmu_bat_get_model_name(struct pmu_battery_info *pbi)
{
switch (pbi->flags & PMU_BATT_TYPE_MASK) {
case PMU_BATT_TYPE_SMART:
return pmu_batt_types[0];
case PMU_BATT_TYPE_COMET:
return pmu_batt_types[1];
case PMU_BATT_TYPE_HOOPER:
return pmu_batt_types[2];
default: break;
}
return pmu_batt_types[3];
}
static int pmu_bat_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct pmu_battery_dev *pbat = to_pmu_battery_dev(psy);
struct pmu_battery_info *pbi = pbat->pbi;
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
if (pbi->flags & PMU_BATT_CHARGING)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else if (pmu_power_flags & PMU_PWR_AC_PRESENT)
val->intval = POWER_SUPPLY_STATUS_FULL;
else
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break;
case POWER_SUPPLY_PROP_PRESENT:
val->intval = !!(pbi->flags & PMU_BATT_PRESENT);
break;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = pmu_bat_get_model_name(pbi);
break;
case POWER_SUPPLY_PROP_ENERGY_AVG:
val->intval = pbi->charge * 1000; /* mWh -> µWh */
break;
case POWER_SUPPLY_PROP_ENERGY_FULL:
val->intval = pbi->max_charge * 1000; /* mWh -> µWh */
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
val->intval = pbi->amperage * 1000; /* mA -> µA */
break;
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
val->intval = pbi->voltage * 1000; /* mV -> µV */
break;
case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
val->intval = pbi->time_remaining;
break;
default:
return -EINVAL;
}
return 0;
}
static enum power_supply_property pmu_bat_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_ENERGY_AVG,
POWER_SUPPLY_PROP_ENERGY_FULL,
POWER_SUPPLY_PROP_CURRENT_AVG,
POWER_SUPPLY_PROP_VOLTAGE_AVG,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
};
/*********************************************************************
* Initialisation
*********************************************************************/
static struct platform_device *bat_pdev;
static int __init pmu_bat_init(void)
{
int ret = 0;
int i;
bat_pdev = platform_device_register_simple("pmu-battery",
0, NULL, 0);
if (IS_ERR(bat_pdev)) {
ret = PTR_ERR(bat_pdev);
goto pdev_register_failed;
}
pmu_ac = power_supply_register(&bat_pdev->dev, &pmu_ac_desc, NULL);
if (IS_ERR(pmu_ac)) {
ret = PTR_ERR(pmu_ac);
goto ac_register_failed;
}
for (i = 0; i < pmu_battery_count; i++) {
struct power_supply_config psy_cfg = {};
struct pmu_battery_dev *pbat = kzalloc(sizeof(*pbat),
GFP_KERNEL);
if (!pbat)
break;
sprintf(pbat->name, "PMU_battery_%d", i);
pbat->bat_desc.name = pbat->name;
pbat->bat_desc.properties = pmu_bat_props;
pbat->bat_desc.num_properties = ARRAY_SIZE(pmu_bat_props);
pbat->bat_desc.get_property = pmu_bat_get_property;
pbat->pbi = &pmu_batteries[i];
psy_cfg.drv_data = pbat;
pbat->bat = power_supply_register(&bat_pdev->dev,
&pbat->bat_desc,
&psy_cfg);
if (IS_ERR(pbat->bat)) {
ret = PTR_ERR(pbat->bat);
kfree(pbat);
goto battery_register_failed;
}
pbats[i] = pbat;
}
goto success;
battery_register_failed:
while (i--) {
if (!pbats[i])
continue;
power_supply_unregister(pbats[i]->bat);
kfree(pbats[i]);
}
power_supply_unregister(pmu_ac);
ac_register_failed:
platform_device_unregister(bat_pdev);
pdev_register_failed:
success:
return ret;
}
static void __exit pmu_bat_exit(void)
{
int i;
for (i = 0; i < PMU_MAX_BATTERIES; i++) {
if (!pbats[i])
continue;
power_supply_unregister(pbats[i]->bat);
kfree(pbats[i]);
}
power_supply_unregister(pmu_ac);
platform_device_unregister(bat_pdev);
}
module_init(pmu_bat_init);
module_exit(pmu_bat_exit);
MODULE_AUTHOR("David Woodhouse <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("PMU battery driver");
| {
"pile_set_name": "Github"
} |
//
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 25 2017 03:49:04).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import "TPropertyImageViewController.h"
@interface TPropertyIconController : TPropertyImageViewController
{
struct TFENodeVector _nodes;
_Bool _nodesHaveSameIcon;
_Bool _nodesHaveCustomIcon;
_Bool _nodesCanChangeIcon;
struct TNotificationCenterObserver _backingPropertiesChangedObserver;
struct TKeyValueObserver _effectiveAppearanceObserver;
}
- (id).cxx_construct;
- (void).cxx_destruct;
- (void)aboutToTearDown;
- (_Bool)progressState:(unsigned int *)arg1 amount:(unsigned int *)arg2 cancellable:(_Bool *)arg3;
- (void)concludeDragOperation:(id)arg1;
- (void)paste:(id)arg1;
- (_Bool)validatePaste:(id)arg1;
- (void)delete:(id)arg1;
- (_Bool)validateDelete:(id)arg1;
- (void)cut:(id)arg1;
- (_Bool)validateCut:(id)arg1;
- (void)copy:(id)arg1;
- (_Bool)validateCopy:(id)arg1;
- (_Bool)canModifyNodes:(const struct TFENodeVector *)arg1;
- (void)updateWithNodes:(const struct TFENodeVector *)arg1;
- (void)viewLoaded;
- (void)initCommon;
@end
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Image</title>
<link type="text/css" rel="stylesheet" href="../fpdf.css">
</head>
<body>
<h1>Image</h1>
<code>Image(<b>string</b> file [, <b>float</b> x [, <b>float</b> y [, <b>float</b> w [, <b>float</b> h [, <b>string</b> type [, <b>mixed</b> link]]]]]])</code>
<h2>Description</h2>
Puts an image. The size it will take on the page can be specified in different ways:
<ul>
<li>explicit width and height (expressed in user unit or dpi)</li>
<li>one explicit dimension, the other being calculated automatically in order to keep the original proportions</li>
<li>no explicit dimension, in which case the image is put at 96 dpi</li>
</ul>
Supported formats are JPEG, PNG and GIF. The GD extension is required for GIF.
<br>
<br>
For JPEGs, all flavors are allowed:
<ul>
<li>gray scales</li>
<li>true colors (24 bits)</li>
<li>CMYK (32 bits)</li>
</ul>
For PNGs, are allowed:
<ul>
<li>gray scales on at most 8 bits (256 levels)</li>
<li>indexed colors</li>
<li>true colors (24 bits)</li>
</ul>
For GIFs: in case of an animated GIF, only the first frame is displayed.<br>
<br>
Transparency is supported.<br>
<br>
The format can be specified explicitly or inferred from the file extension.<br>
<br>
It is possible to put a link on the image.<br>
<br>
Remark: if an image is used several times, only one copy is embedded in the file.
<h2>Parameters</h2>
<dl class="param">
<dt><code>file</code></dt>
<dd>
Path or URL of the image.
</dd>
<dt><code>x</code></dt>
<dd>
Abscissa of the upper-left corner. If not specified or equal to <code>null</code>, the current abscissa
is used.
</dd>
<dt><code>y</code></dt>
<dd>
Ordinate of the upper-left corner. If not specified or equal to <code>null</code>, the current ordinate
is used; moreover, a page break is triggered first if necessary (in case automatic page breaking is enabled)
and, after the call, the current ordinate is moved to the bottom of the image.
</dd>
<dt><code>w</code></dt>
<dd>
Width of the image in the page. There are three cases:
<ul>
<li>If the value is positive, it represents the width in user unit</li>
<li>If the value is negative, the absolute value represents the horizontal resolution in dpi</li>
<li>If the value is not specified or equal to zero, it is automatically calculated</li>
</ul>
</dd>
<dt><code>h</code></dt>
<dd>
Height of the image in the page. There are three cases:
<ul>
<li>If the value is positive, it represents the height in user unit</li>
<li>If the value is negative, the absolute value represents the vertical resolution in dpi</li>
<li>If the value is not specified or equal to zero, it is automatically calculated</li>
</ul>
</dd>
<dt><code>type</code></dt>
<dd>
Image format. Possible values are (case insensitive): <code>JPG</code>, <code>JPEG</code>, <code>PNG</code> and <code>GIF</code>.
If not specified, the type is inferred from the file extension.
</dd>
<dt><code>link</code></dt>
<dd>
URL or identifier returned by AddLink().
</dd>
</dl>
<h2>Example</h2>
<div class="doc-source">
<pre><code>// Insert a logo in the top-left corner at 300 dpi
$pdf->Image('logo.png',10,10,-300);
// Insert a dynamic image from a URL
$pdf->Image('http://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World',60,30,90,0,'PNG');</code></pre>
</div>
<h2>See also</h2>
<a href="addlink.htm">AddLink</a>
<hr style="margin-top:1.5em">
<div style="text-align:center"><a href="index.htm">Index</a></div>
</body>
</html>
| {
"pile_set_name": "Github"
} |
var SourceMapConsumer = require('source-map').SourceMapConsumer;
var fs = require('fs');
var path = require('path');
var http = require('http');
var https = require('https');
var url = require('url');
var override = require('../utils/object.js').override;
var MAP_MARKER = /\/\*# sourceMappingURL=(\S+) \*\//;
var REMOTE_RESOURCE = /^(https?:)?\/\//;
var DATA_URI = /^data:(\S*?)?(;charset=[^;]+)?(;[^,]+?)?,(.+)/;
var unescape = global.unescape;
function InputSourceMapStore(outerContext) {
this.options = outerContext.options;
this.errors = outerContext.errors;
this.warnings = outerContext.warnings;
this.sourceTracker = outerContext.sourceTracker;
this.timeout = this.options.inliner.timeout;
this.requestOptions = this.options.inliner.request;
this.localOnly = outerContext.localOnly;
this.relativeTo = outerContext.options.target || process.cwd();
this.maps = {};
this.sourcesContent = {};
}
function fromString(self, _, whenDone) {
self.trackLoaded(undefined, undefined, self.options.sourceMap);
return whenDone();
}
function fromSource(self, data, whenDone, context) {
var nextAt = 0;
function proceedToNext() {
context.cursor += nextAt + 1;
fromSource(self, data, whenDone, context);
}
while (context.cursor < data.length) {
var fragment = data.substring(context.cursor);
var markerStartMatch = self.sourceTracker.nextStart(fragment) || { index: -1 };
var markerEndMatch = self.sourceTracker.nextEnd(fragment) || { index: -1 };
var mapMatch = MAP_MARKER.exec(fragment) || { index: -1 };
var sourceMapFile = mapMatch[1];
nextAt = data.length;
if (markerStartMatch.index > -1)
nextAt = markerStartMatch.index;
if (markerEndMatch.index > -1 && markerEndMatch.index < nextAt)
nextAt = markerEndMatch.index;
if (mapMatch.index > -1 && mapMatch.index < nextAt)
nextAt = mapMatch.index;
if (nextAt == data.length)
break;
if (nextAt == markerStartMatch.index) {
context.files.push(markerStartMatch.filename);
} else if (nextAt == markerEndMatch.index) {
context.files.pop();
} else if (nextAt == mapMatch.index) {
var isRemote = /^https?:\/\//.test(sourceMapFile) || /^\/\//.test(sourceMapFile);
var isDataUri = DATA_URI.test(sourceMapFile);
if (isRemote) {
return fetchMapFile(self, sourceMapFile, context, proceedToNext);
} else {
var sourceFile = context.files[context.files.length - 1];
var sourceMapPath, sourceMapData;
var sourceDir = sourceFile ? path.dirname(sourceFile) : self.options.relativeTo;
if (isDataUri) {
// source map's path is the same as the source file it comes from
sourceMapPath = path.resolve(self.options.root, sourceFile || '');
sourceMapData = fromDataUri(sourceMapFile);
} else {
sourceMapPath = path.resolve(self.options.root, path.join(sourceDir || '', sourceMapFile));
sourceMapData = fs.readFileSync(sourceMapPath, 'utf-8');
}
self.trackLoaded(sourceFile || undefined, sourceMapPath, sourceMapData);
}
}
context.cursor += nextAt + 1;
}
return whenDone();
}
function fromDataUri(uriString) {
var match = DATA_URI.exec(uriString);
var charset = match[2] ? match[2].split(/[=;]/)[2] : 'us-ascii';
var encoding = match[3] ? match[3].split(';')[1] : 'utf8';
var data = encoding == 'utf8' ? unescape(match[4]) : match[4];
var buffer = new Buffer(data, encoding);
buffer.charset = charset;
return buffer.toString();
}
function fetchMapFile(self, sourceUrl, context, done) {
fetch(self, sourceUrl, function (data) {
self.trackLoaded(context.files[context.files.length - 1] || undefined, sourceUrl, data);
done();
}, function (message) {
context.errors.push('Broken source map at "' + sourceUrl + '" - ' + message);
return done();
});
}
function fetch(self, path, onSuccess, onFailure) {
var protocol = path.indexOf('https') === 0 ? https : http;
var requestOptions = override(url.parse(path), self.requestOptions);
var errorHandled = false;
protocol
.get(requestOptions, function (res) {
if (res.statusCode < 200 || res.statusCode > 299)
return onFailure(res.statusCode);
var chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk.toString());
});
res.on('end', function () {
onSuccess(chunks.join(''));
});
})
.on('error', function (res) {
if (errorHandled)
return;
onFailure(res.message);
errorHandled = true;
})
.on('timeout', function () {
if (errorHandled)
return;
onFailure('timeout');
errorHandled = true;
})
.setTimeout(self.timeout);
}
function originalPositionIn(trackedSource, line, column, token, allowNFallbacks) {
var originalPosition;
var maxRange = token.length;
var position = {
line: line,
column: column + maxRange
};
while (maxRange-- > 0) {
position.column--;
originalPosition = trackedSource.data.originalPositionFor(position);
if (originalPosition)
break;
}
if (originalPosition.line === null && line > 1 && allowNFallbacks > 0)
return originalPositionIn(trackedSource, line - 1, column, token, allowNFallbacks - 1);
if (trackedSource.path && originalPosition.source) {
originalPosition.source = REMOTE_RESOURCE.test(trackedSource.path) ?
url.resolve(trackedSource.path, originalPosition.source) :
path.join(trackedSource.path, originalPosition.source);
originalPosition.sourceResolved = true;
}
return originalPosition;
}
function trackContentSources(self, sourceFile) {
var consumer = self.maps[sourceFile].data;
var isRemote = REMOTE_RESOURCE.test(sourceFile);
var sourcesMapping = {};
consumer.sources.forEach(function (file, index) {
var uniquePath = isRemote ?
url.resolve(path.dirname(sourceFile), file) :
path.relative(self.relativeTo, path.resolve(path.dirname(sourceFile), file));
sourcesMapping[uniquePath] = consumer.sourcesContent && consumer.sourcesContent[index];
});
self.sourcesContent[sourceFile] = sourcesMapping;
}
function _resolveSources(self, remaining, whenDone) {
function processNext() {
return _resolveSources(self, remaining, whenDone);
}
if (remaining.length === 0)
return whenDone();
var current = remaining.shift();
var sourceFile = current[0];
var originalFile = current[1];
var isRemote = REMOTE_RESOURCE.test(sourceFile);
if (isRemote && self.localOnly) {
self.warnings.push('No callback given to `#minify` method, cannot fetch a remote file from "' + originalFile + '"');
return processNext();
}
if (isRemote) {
fetch(self, originalFile, function (data) {
self.sourcesContent[sourceFile][originalFile] = data;
processNext();
}, function (message) {
self.warnings.push('Broken original source file at "' + originalFile + '" - ' + message);
processNext();
});
} else {
var fullPath = path.join(self.options.root, originalFile);
if (fs.existsSync(fullPath))
self.sourcesContent[sourceFile][originalFile] = fs.readFileSync(fullPath, 'utf-8');
else
self.warnings.push('Missing original source file at "' + fullPath + '".');
return processNext();
}
}
InputSourceMapStore.prototype.track = function (data, whenDone) {
return typeof this.options.sourceMap == 'string' ?
fromString(this, data, whenDone) :
fromSource(this, data, whenDone, { files: [], cursor: 0, errors: this.errors });
};
InputSourceMapStore.prototype.trackLoaded = function (sourcePath, mapPath, mapData) {
var relativeTo = this.options.explicitTarget ? this.options.target : this.options.root;
var isRemote = REMOTE_RESOURCE.test(sourcePath);
if (mapPath) {
mapPath = isRemote ?
path.dirname(mapPath) :
path.dirname(path.relative(relativeTo, mapPath));
}
this.maps[sourcePath] = {
path: mapPath,
data: new SourceMapConsumer(mapData)
};
trackContentSources(this, sourcePath);
};
InputSourceMapStore.prototype.isTracking = function (source) {
return !!this.maps[source];
};
InputSourceMapStore.prototype.originalPositionFor = function (sourceInfo, token, allowNFallbacks) {
return originalPositionIn(this.maps[sourceInfo.source], sourceInfo.line, sourceInfo.column, token, allowNFallbacks);
};
InputSourceMapStore.prototype.sourcesContentFor = function (contextSource) {
return this.sourcesContent[contextSource];
};
InputSourceMapStore.prototype.resolveSources = function (whenDone) {
var toResolve = [];
for (var sourceFile in this.sourcesContent) {
var contents = this.sourcesContent[sourceFile];
for (var originalFile in contents) {
if (!contents[originalFile])
toResolve.push([sourceFile, originalFile]);
}
}
return _resolveSources(this, toResolve, whenDone);
};
module.exports = InputSourceMapStore;
| {
"pile_set_name": "Github"
} |
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE680_Integer_Overflow_to_Buffer_Overflow__new_fgets_53d.cpp
Label Definition File: CWE680_Integer_Overflow_to_Buffer_Overflow__new.label.xml
Template File: sources-sink-53d.tmpl.cpp
*/
/*
* @description
* CWE: 680 Integer Overflow to Buffer Overflow
* BadSource: fgets Read data from the console using fgets()
* GoodSource: Small number greater than zero that will not cause an integer overflow in the sink
* Sink:
* BadSink : Attempt to allocate array using length value from source
* Flow Variant: 53 Data flow: data passed as an argument from one function through two others to a fourth; all four functions are in different source files
*
* */
#include "std_testcase.h"
#define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
namespace CWE680_Integer_Overflow_to_Buffer_Overflow__new_fgets_53
{
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
void badSink_d(int data)
{
{
size_t dataBytes,i;
int *intPointer;
/* POTENTIAL FLAW: dataBytes may overflow to a small value */
dataBytes = data * sizeof(int); /* sizeof array in bytes */
intPointer = (int*)new char[dataBytes];
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* may write beyond limit of intPointer if integer overflow occured above */
}
printIntLine(intPointer[0]);
delete [] intPointer;
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink_d(int data)
{
{
size_t dataBytes,i;
int *intPointer;
/* POTENTIAL FLAW: dataBytes may overflow to a small value */
dataBytes = data * sizeof(int); /* sizeof array in bytes */
intPointer = (int*)new char[dataBytes];
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* may write beyond limit of intPointer if integer overflow occured above */
}
printIntLine(intPointer[0]);
delete [] intPointer;
}
}
#endif /* OMITGOOD */
} /* close namespace */
| {
"pile_set_name": "Github"
} |
// flex type
@mixin d-flex(){
display: flex;
}
@mixin d-inline-flex(){
display: inline-flex;
}
// flex-direction
@mixin flex-row(){
flex-direction: row;
}
@mixin flex-row-reverse(){
flex-direction: row;
}
@mixin flex-column(){
flex-direction: column;
}
@mixin flex-column-reverse(){
flex-direction: column-reverse;
}
// flex-flow
@mixin flex-flow-rw(){
flex-flow: row wrap;
}
@mixin flex-flow-rrw(){
flex-flow: row-reverse wrap;
}
@mixin flex-flow-rnw(){
flex-flow: row nowrap;
}
@mixin flex-flow-rrnw(){
flex-flow: row-reverse nowrap;
}
@mixin flex-flow-cw(){
flex-flow: column wrap;
}
@mixin flex-flow-crw(){
flex-flow: column-reverse wrap;
}
@mixin flex-flow-cnw(){
flex-flow: column nowrap;
}
@mixin flex-flow-crnw(){
flex-flow: column-reverse nowrap;
}
// flex-wrap
@mixin flex-wrap(){
flex-wrap: wrap;
}
@mixin flex-wrap-reverse(){
flex-wrap: wrap-reverse;
}
@mixin flex-nowrap(){
flex-wrap: nowrap;
}
// Justfy-content
@mixin justfy-content-start(){
justify-content: flex-start;
}
@mixin justfy-content-end(){
justify-content: flex-end;
}
@mixin justfy-content-center(){
justify-content: center;
}
@mixin justfy-content-baseline(){
justify-content: baseline;
}
@mixin justfy-content-stretch(){
justify-content: stretch;
}
// align-items
@mixin align-items-start(){
align-items: flex-start;
}
@mixin align-items-end(){
align-items: flex-end;
}
@mixin align-items-center(){
align-items: center;
}
@mixin align-items-between(){
align-items: space-between;
}
@mixin align-items-arround(){
align-items: space-around;
}
// align-self
@mixin align-self-start(){
align-self: flex-start;
}
@mixin align-self-end(){
align-self: flex-end;
}
@mixin align-self-center(){
align-self: center;
}
@mixin align-self-baseline(){
align-self: baseline;
}
@mixin align-self-stretch(){
align-self: stretch;
}
// align-content
@mixin align-content-start(){
align-content: flex-start;
}
@mixin align-content-end(){
align-content: flex-end;
}
@mixin align-content-center(){
align-content: center;
}
@mixin align-content-baseline(){
align-content: baseline;
}
@mixin align-self-stretch(){
align-self: stretch;
}
// flex order
@mixin flex-order-first(){
order: -1;
}
@mixin flex-order-last(){
order: 1;
}
@mixin flex-order-unordered(){
order: 0;
}
// Auto Margin Left-Righ (justfy-content)
@mixin ml-auto(){
margin-left: auto;
}
@mixin mr-auto(){
margin-right: auto;
}
// Auto Margin Top-Bottom (align-items)
@mixin mt-auto(){
margin-top: auto;
}
@mixin mb-auto(){
margin-bottom: auto;
}
// clearfix
@mixin clearfix() {
&::after {
display: block;
clear: both;
content: "";
}
}
| {
"pile_set_name": "Github"
} |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jit_MIRGenerator_h
#define jit_MIRGenerator_h
// This file declares the data structures used to build a control-flow graph
// containing MIR.
#include "mozilla/Atomics.h"
#include <stdarg.h>
#include "jscntxt.h"
#include "jscompartment.h"
#include "jit/CompileInfo.h"
#include "jit/IonAllocPolicy.h"
#include "jit/JitCompartment.h"
#ifdef JS_ION_PERF
# include "jit/PerfSpewer.h"
#endif
#include "jit/RegisterSets.h"
namespace js {
namespace jit {
class MBasicBlock;
class MIRGraph;
class MStart;
class OptimizationInfo;
class MIRGenerator
{
public:
MIRGenerator(CompileCompartment *compartment, const JitCompileOptions &options,
TempAllocator *alloc, MIRGraph *graph,
CompileInfo *info, const OptimizationInfo *optimizationInfo);
TempAllocator &alloc() {
return *alloc_;
}
MIRGraph &graph() {
return *graph_;
}
bool ensureBallast() {
return alloc().ensureBallast();
}
const JitRuntime *jitRuntime() const {
return GetIonContext()->runtime->jitRuntime();
}
CompileInfo &info() {
return *info_;
}
const OptimizationInfo &optimizationInfo() const {
return *optimizationInfo_;
}
template <typename T>
T * allocate(size_t count = 1) {
if (count & mozilla::tl::MulOverflowMask<sizeof(T)>::value)
return nullptr;
return reinterpret_cast<T *>(alloc().allocate(sizeof(T) * count));
}
// Set an error state and prints a message. Returns false so errors can be
// propagated up.
bool abort(const char *message, ...);
bool abortFmt(const char *message, va_list ap);
bool errored() const {
return error_;
}
bool instrumentedProfiling() {
if (!instrumentedProfilingIsCached_) {
instrumentedProfiling_ = GetIonContext()->runtime->spsProfiler().enabled();
instrumentedProfilingIsCached_ = true;
}
return instrumentedProfiling_;
}
bool isNativeToBytecodeMapEnabled() {
if (compilingAsmJS())
return false;
#ifdef DEBUG
return true;
#else
return instrumentedProfiling();
#endif
}
// Whether the main thread is trying to cancel this build.
bool shouldCancel(const char *why) {
maybePause();
return cancelBuild_;
}
void cancel() {
cancelBuild_ = true;
}
void maybePause() {
if (pauseBuild_ && *pauseBuild_)
PauseCurrentHelperThread();
}
void setPauseFlag(mozilla::Atomic<bool, mozilla::Relaxed> *pauseBuild) {
pauseBuild_ = pauseBuild;
}
void disable() {
abortReason_ = AbortReason_Disable;
}
AbortReason abortReason() {
return abortReason_;
}
bool compilingAsmJS() const {
return info_->compilingAsmJS();
}
uint32_t maxAsmJSStackArgBytes() const {
JS_ASSERT(compilingAsmJS());
return maxAsmJSStackArgBytes_;
}
uint32_t resetAsmJSMaxStackArgBytes() {
JS_ASSERT(compilingAsmJS());
uint32_t old = maxAsmJSStackArgBytes_;
maxAsmJSStackArgBytes_ = 0;
return old;
}
void setAsmJSMaxStackArgBytes(uint32_t n) {
JS_ASSERT(compilingAsmJS());
maxAsmJSStackArgBytes_ = n;
}
void setPerformsCall() {
performsCall_ = true;
}
bool performsCall() const {
return performsCall_;
}
// Traverses the graph to find if there's any SIMD instruction. Costful but
// the value is cached, so don't worry about calling it several times.
bool usesSimd();
void initMinAsmJSHeapLength(uint32_t len) {
JS_ASSERT(minAsmJSHeapLength_ == 0);
minAsmJSHeapLength_ = len;
}
uint32_t minAsmJSHeapLength() const {
return minAsmJSHeapLength_;
}
bool modifiesFrameArguments() const {
return modifiesFrameArguments_;
}
public:
CompileCompartment *compartment;
protected:
CompileInfo *info_;
const OptimizationInfo *optimizationInfo_;
TempAllocator *alloc_;
JSFunction *fun_;
uint32_t nslots_;
MIRGraph *graph_;
AbortReason abortReason_;
bool error_;
mozilla::Atomic<bool, mozilla::Relaxed> *pauseBuild_;
mozilla::Atomic<bool, mozilla::Relaxed> cancelBuild_;
uint32_t maxAsmJSStackArgBytes_;
bool performsCall_;
bool usesSimd_;
bool usesSimdCached_;
uint32_t minAsmJSHeapLength_;
// Keep track of whether frame arguments are modified during execution.
// RegAlloc needs to know this as spilling values back to their register
// slots is not compatible with that.
bool modifiesFrameArguments_;
bool instrumentedProfiling_;
bool instrumentedProfilingIsCached_;
#if defined(JS_ION_PERF)
AsmJSPerfSpewer asmJSPerfSpewer_;
public:
AsmJSPerfSpewer &perfSpewer() { return asmJSPerfSpewer_; }
#endif
public:
const JitCompileOptions options;
};
} // namespace jit
} // namespace js
#endif /* jit_MIRGenerator_h */
| {
"pile_set_name": "Github"
} |
/**
* @file
* @brief Tools for file edition
* @author Denis Deryugin <[email protected]>
* @version 0.1
* @date 2016-01-15
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <lib/edit.h>
#include <../../../compat/libc/stdio/file_struct.h>
int fdelete_from_file(int fd, size_t length) {
char buf[128];
int i;
int err;
off_t size;
off_t pos;
int cnt;
memset(buf, 0, sizeof(buf));
pos = lseek(fd, 0, SEEK_CUR);
size = lseek(fd, 0, SEEK_END);
cnt = (size - (pos + length) + sizeof(buf) - 1) / sizeof(buf);
for (i = 0; i < cnt; i++) {
if (lseek(fd, pos + sizeof(buf) * i + length, SEEK_SET) < 0)
return -1;
if (read(fd, buf, sizeof(buf)) < 0)
return -1;
if (lseek(fd, pos + sizeof(buf) * i, SEEK_SET) < 0)
return -1;
if (write(fd, buf, sizeof(buf)))
return -1;
}
if ((err = ftruncate(fd, size - length)))
return err;
return 0;
}
int finsert_into_file(int fd, char *buf, size_t length) {
char tmp[128];
int i;
int err;
off_t size;
off_t pos;
int cnt;
assert(buf);
memset(tmp, 0, sizeof(tmp));
pos = lseek(fd, 0, SEEK_CUR);
size = lseek(fd, 0, SEEK_END);
cnt = (size - pos + sizeof(tmp) - 1) / sizeof(tmp);
for (i = cnt - 1; i >= 0; i--) {
if (lseek(fd, pos + sizeof(tmp) * i, SEEK_SET) < 0)
return -1;
if (read(fd, tmp, sizeof(tmp)) < 0)
return -1;
if (lseek(fd, pos + sizeof(tmp) * i + length, SEEK_SET) < 0)
return -1;
if (write(fd, tmp, sizeof(tmp)) < 0)
return -1;
}
if (lseek(fd, pos, SEEK_SET) < 0)
return -1;
if (write(fd, buf, length) < 0)
return -1;
if ((err = ftruncate(fd, size + length)))
return err;
return 0;
}
int delete_from_file(FILE *file, size_t length) {
return fdelete_from_file(file->fd, length);
}
int insert_into_file(FILE *file, char *buf, size_t length) {
return finsert_into_file(file->fd, buf, length);
}
| {
"pile_set_name": "Github"
} |
-1441164325:LMT:0:12324
193623924:+03:0:10800
1602453600:+05:0:18000
15807600:+06:1:21600
15724800:+06:0:21600
15811200:+06:1:21600
15728400:+05:0:18000
15807600:+06:1:21600
15814800:+05:0:18000
15732000:+06:1:21600
15724800:+05:0:18000
15724800:+06:1:21600
15724800:+05:0:18000
15724800:+06:1:21600
15724800:+05:0:18000
15724800:+06:1:21600
15724800:+05:0:18000
15724800:+06:1:21600
15724800:+05:0:18000
15728400:+05:1:18000
15724800:+04:0:14400
16329600:+05:1:18000
15724800:+04:0:14400
15724800:+05:1:18000
9676800:+04:0:14400
6044400:+05:0:18000
15728400:+05:1:18000
15724800:+04:0:14400
15724800:+05:1:18000
15724800:+04:0:14400
15724800:+05:1:18000
15724800:+04:0:14400
15724800:+05:1:18000
16329600:+04:0:14400
18144000:+05:1:18000
13305600:+04:0:14400
18144000:+05:1:18000
13305600:+04:0:14400
18144000:+05:1:18000
13305600:+04:0:14400
18748800:+05:1:18000
12700800:+04:0:14400
18748800:+05:1:18000
12700800:+04:0:14400
18748800:+05:1:18000
13305600:+04:0:14400
18144000:+05:1:18000
13305600:+04:0:14400
18144000:+05:1:18000
13305600:+04:0:14400
18748800:+05:1:18000
1:+05:0:18000 | {
"pile_set_name": "Github"
} |
package sample.distributeddata
import akka.actor.Actor
import akka.actor.ActorLogging
import akka.actor.ActorRef
import akka.actor.Props
import akka.actor.Terminated
import akka.cluster.Cluster
import akka.cluster.ClusterEvent
import akka.cluster.ClusterEvent.LeaderChanged
import akka.cluster.ddata.DistributedData
import akka.cluster.ddata.GSet
import akka.cluster.ddata.GSetKey
import akka.cluster.ddata.Key
import akka.cluster.ddata.ORSet
object ServiceRegistry {
import akka.cluster.ddata.Replicator._
val props: Props = Props[ServiceRegistry]
/**
* Register a `service` with a `name`. Several services
* can be registered with the same `name`.
* It will be removed when it is terminated.
*/
final case class Register(name: String, service: ActorRef)
/**
* Lookup services registered for a `name`. [[Bindings]] will
* be sent to `sender()`.
*/
final case class Lookup(name: String)
/**
* Reply for [[Lookup]]
*/
final case class Bindings(name: String, services: Set[ActorRef])
/**
* Published to `ActorSystem.eventStream` when services are changed.
*/
final case class BindingChanged(name: String, services: Set[ActorRef])
final case class ServiceKey(serviceName: String) extends Key[ORSet[ActorRef]](serviceName)
private val AllServicesKey = GSetKey[ServiceKey]("service-keys")
}
class ServiceRegistry extends Actor with ActorLogging {
import akka.cluster.ddata.Replicator._
import ServiceRegistry._
val replicator = DistributedData(context.system).replicator
implicit val cluster = Cluster(context.system)
var keys = Set.empty[ServiceKey]
var services = Map.empty[String, Set[ActorRef]]
var leader = false
def serviceKey(serviceName: String): ServiceKey =
ServiceKey("service:" + serviceName)
override def preStart(): Unit = {
replicator ! Subscribe(AllServicesKey, self)
cluster.subscribe(self, ClusterEvent.InitialStateAsEvents, classOf[ClusterEvent.LeaderChanged])
}
override def postStop(): Unit = {
cluster.unsubscribe(self)
}
def receive = {
case Register(name, service) =>
val dKey = serviceKey(name)
// store the service names in a separate GSet to be able to
// get notifications of new names
if (!keys(dKey))
replicator ! Update(AllServicesKey, GSet(), WriteLocal)(_ + dKey)
// add the service
replicator ! Update(dKey, ORSet(), WriteLocal)(_ + service)
case Lookup(name) =>
sender() ! Bindings(name, services.getOrElse(name, Set.empty))
case c @ Changed(AllServicesKey) =>
val newKeys = c.get(AllServicesKey).elements
log.debug("Services changed, added: {}, all: {}", (newKeys -- keys), newKeys)
(newKeys -- keys).foreach { dKey =>
// subscribe to get notifications of when services with this name are added or removed
replicator ! Subscribe(dKey, self)
}
keys = newKeys
case c @ Changed(ServiceKey(serviceName)) =>
val name = serviceName.split(":").tail.mkString
val newServices = c.get(serviceKey(name)).elements
log.debug("Services changed for name [{}]: {}", name, newServices)
services = services.updated(name, newServices)
context.system.eventStream.publish(BindingChanged(name, newServices))
if (leader)
newServices.foreach(context.watch) // watch is idempotent
case LeaderChanged(node) =>
// Let one node (the leader) be responsible for removal of terminated services
// to avoid redundant work and too many death watch notifications.
// It is not critical to only do it from one node.
val wasLeader = leader
leader = node.exists(_ == cluster.selfAddress)
// when used with many (> 500) services you must increase the system message buffer
// `akka.remote.system-message-buffer-size`
if (!wasLeader && leader)
for (refs ← services.valuesIterator; ref ← refs)
context.watch(ref)
else if (wasLeader && !leader)
for (refs ← services.valuesIterator; ref ← refs)
context.unwatch(ref)
case Terminated(ref) =>
val names = services.collect { case (name, refs) if refs.contains(ref) => name }
names.foreach { name =>
log.debug("Service with name [{}] terminated: {}", name, ref)
replicator ! Update(serviceKey(name), ORSet(), WriteLocal)(_ - ref)
}
case _: UpdateResponse[_] => // ok
}
}
| {
"pile_set_name": "Github"
} |
/**
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
*
* 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.
*
*/
using Newtonsoft.Json;
using System;
namespace IBM.Watson.CompareComply.V1.Model
{
/// <summary>
/// Information about the document and the submitted feedback.
/// </summary>
public class FeedbackReturn
{
/// <summary>
/// The unique ID of the feedback object.
/// </summary>
[JsonProperty("feedback_id", NullValueHandling = NullValueHandling.Ignore)]
public string FeedbackId { get; set; }
/// <summary>
/// An optional string identifying the person submitting feedback.
/// </summary>
[JsonProperty("user_id", NullValueHandling = NullValueHandling.Ignore)]
public string UserId { get; set; }
/// <summary>
/// An optional comment from the person submitting the feedback.
/// </summary>
[JsonProperty("comment", NullValueHandling = NullValueHandling.Ignore)]
public string Comment { get; set; }
/// <summary>
/// Timestamp listing the creation time of the feedback submission.
/// </summary>
[JsonProperty("created", NullValueHandling = NullValueHandling.Ignore)]
public DateTime? Created { get; set; }
/// <summary>
/// Information returned from the **Add Feedback** method.
/// </summary>
[JsonProperty("feedback_data", NullValueHandling = NullValueHandling.Ignore)]
public FeedbackDataOutput FeedbackData { get; set; }
}
}
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.