answer
stringlengths
15
1.25M
package com.intellij.openapi.vcs.roots; import com.google.common.annotations.VisibleForTesting; import com.intellij.idea.ActionsBundle; import com.intellij.notification.Notification; import com.intellij.notification.NotificationAction; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.progress.util.BackgroundTaskUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.*; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Function; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; import static com.intellij.openapi.util.io.FileUtil.<API key>; import static com.intellij.openapi.util.text.StringUtil.escapeXmlEntities; import static com.intellij.openapi.vcs.<API key>.ROOTS_INVALID; import static com.intellij.openapi.vcs.<API key>.ROOTS_REGISTERED; import static com.intellij.openapi.vcs.VcsRootError.Type.UNREGISTERED_ROOT; import static com.intellij.util.containers.ContainerUtil.*; import static com.intellij.util.ui.UIUtil.BR; /** * Searches for Vcs roots problems via {@link VcsRootErrorsFinder} and notifies about them. */ public final class <API key> { private static final Logger LOG = Logger.getInstance(<API key>.class); @NotNull private final Project myProject; @NotNull private final VcsConfiguration mySettings; @NotNull private final <API key> myVcsManager; @NotNull private final ChangeListManager myChangeListManager; @NotNull private final ProjectFileIndex myProjectFileIndex; // unregistered roots reported during this session but not explicitly ignored @NotNull private final Set<String> <API key>; @Nullable private Notification myNotification; @NotNull private final Object NOTIFICATION_LOCK = new Object(); @NotNull private final Function<VcsRootError, String> ROOT_TO_PRESENTABLE = rootError -> <API key>(rootError.getMapping()); public static <API key> createInstance(@NotNull Project project) { return new <API key>(project); } private <API key>(@NotNull Project project) { myProject = project; mySettings = VcsConfiguration.getInstance(myProject); myChangeListManager = ChangeListManager.getInstance(project); myProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(myProject); myVcsManager = <API key>.getInstance(project); <API key> = new HashSet<>(); } public void <API key>() { Collection<VcsRootError> errors = scan(); if (errors.isEmpty()) { synchronized (NOTIFICATION_LOCK) { expireNotification(); } return; } LOG.debug("Following errors detected: " + errors); Collection<VcsRootError> <API key> = <API key>(errors); Collection<VcsRootError> invalidRoots = getInvalidRoots(errors); String title; String description; NotificationAction[] notificationActions; if (Registry.is("vcs.root.auto.add") && !<API key>(errors)) { if (invalidRoots.isEmpty() && <API key>.isEmpty()) return; LOG.info("Auto-registered following mappings: " + <API key>); addMappings(<API key>); // Register the single root equal to the project dir silently, without any notification if (invalidRoots.isEmpty() && <API key>.size() == 1) { VcsRootError rootError = Objects.requireNonNull(getFirstItem(<API key>)); if (FileUtil.pathsEqual(rootError.getMapping().getDirectory(), myProject.getBasePath())) { return; } } // Don't display the notification about registered roots unless configured to do so (and unless there are invalid roots) if (invalidRoots.isEmpty() && !Registry.is("vcs.root.auto.add.nofity")) { return; } title = makeTitle(<API key>, invalidRoots, true); description = makeDescription(<API key>, invalidRoots); notificationActions = new NotificationAction[]{<API key>()}; } else { // Don't report again, if these roots were already reported List<String> unregRootPaths = map(<API key>, rootError -> rootError.getMapping().getDirectory()); if (invalidRoots.isEmpty() && (<API key>.isEmpty() || <API key>.containsAll(unregRootPaths))) { return; } <API key>.addAll(unregRootPaths); title = makeTitle(<API key>, invalidRoots, false); description = makeDescription(<API key>, invalidRoots); NotificationAction enableIntegration = NotificationAction .create(VcsBundle.messagePointer("action.NotificationAction.<API key>.text.enable.integration"), (event, notification) -> addMappings(<API key>)); NotificationAction ignoreAction = NotificationAction .create(VcsBundle.messagePointer("action.NotificationAction.<API key>.text.ignore"), (event, notification) -> { mySettings.<API key>(map(<API key>, rootError -> rootError.getMapping().getDirectory())); notification.expire(); }); notificationActions = new NotificationAction[]{enableIntegration, <API key>(), ignoreAction}; } synchronized (NOTIFICATION_LOCK) { expireNotification(); VcsNotifier notifier = VcsNotifier.getInstance(myProject); myNotification = invalidRoots.isEmpty() ? notifier.notifyMinorInfo(ROOTS_REGISTERED, title, description, notificationActions) : notifier.notifyError(ROOTS_INVALID, title, description, <API key>()); } } @NotNull private NotificationAction <API key>() { return NotificationAction.create(VcsBundle.messagePointer("action.NotificationAction.<API key>.text.configure"), (event, notification) -> { if (!myProject.isDisposed()) { ShowSettingsUtil.getInstance().showSettingsDialog(myProject, ActionsBundle.message("group.VcsGroup.text")); BackgroundTaskUtil.<API key>(myProject, () -> { Collection<VcsRootError> <API key> = new <API key>(myProject).scan(); if (<API key>.isEmpty() && !notification.isExpired()) { notification.expire(); } }); } }); } private void addMappings(Collection<? extends VcsRootError> <API key>) { List<VcsDirectoryMapping> mappings = myVcsManager.<API key>(); for (VcsRootError root : <API key>) { mappings = VcsUtil.addMapping(mappings, root.getMapping()); } myVcsManager.<API key>(mappings); } private boolean <API key>(@NotNull VcsDirectoryMapping mapping) { String projectDir = Objects.requireNonNull(myProject.getBasePath()); return mapping.isDefaultMapping() || FileUtil.isAncestor(projectDir, mapping.getDirectory(), false) || FileUtil.isAncestor(mapping.getDirectory(), projectDir, false); } private boolean <API key>(@NotNull VcsDirectoryMapping mapping) { if (mapping.isDefaultMapping()) return false; VirtualFile file = LocalFileSystem.getInstance().findFileByPath(mapping.getDirectory()); return file != null && (myChangeListManager.isIgnoredFile(file) || ReadAction.compute(() -> myProjectFileIndex.isExcluded(file))); } private boolean <API key>(@NotNull VcsDirectoryMapping mapping) { if (mapping.isDefaultMapping()) return false; return mySettings.<API key>(mapping.getDirectory()); } private void expireNotification() { if (myNotification != null) { final Notification notification = myNotification; ApplicationManager.getApplication().invokeLater(notification::expire); myNotification = null; } } @NotNull private Collection<VcsRootError> scan() { return new VcsRootErrorsFinder(myProject).find(); } @NotNull private @NlsContexts.NotificationContent String makeDescription(@NotNull Collection<? extends VcsRootError> unregisteredRoots, @NotNull Collection<? extends VcsRootError> invalidRoots) { @Nls StringBuilder description = new StringBuilder(); if (!invalidRoots.isEmpty()) { if (invalidRoots.size() == 1) { VcsRootError rootError = invalidRoots.iterator().next(); String vcsName = rootError.getMapping().getVcs(); description.append(<API key>(rootError, vcsName)); } else { description.append(VcsBundle.message("roots.the.following.directories.are.registered.as.vcs.roots.but.they.are.not")) .append(BR) .append(<API key>(invalidRoots)); } description.append(BR); } if (!unregisteredRoots.isEmpty()) { if (unregisteredRoots.size() == 1) { VcsRootError unregisteredRoot = unregisteredRoots.iterator().next(); description.append(ROOT_TO_PRESENTABLE.fun(unregisteredRoot)); } else { description.append(<API key>(unregisteredRoots)); } } return description.toString(); } @VisibleForTesting @NlsContexts.NotificationContent @NotNull String <API key>(@NotNull VcsRootError rootError, @NotNull String vcsName) { return VcsBundle.message("roots.notification.content.directory.registered.as.root.but.no.repositories.were.found.there", ROOT_TO_PRESENTABLE.fun(rootError), vcsName); } @NotNull private String <API key>(@NotNull Collection<? extends VcsRootError> errors) { List<? extends VcsRootError> sortedRoots = sorted(errors, (root1, root2) -> { if (root1.getMapping().isDefaultMapping()) return -1; if (root2.getMapping().isDefaultMapping()) return 1; return root1.getMapping().getDirectory().compareTo(root2.getMapping().getDirectory()); }); return StringUtil.join(sortedRoots, ROOT_TO_PRESENTABLE, BR); } @NotNull private static @NlsContexts.NotificationTitle String makeTitle(@NotNull Collection<? extends VcsRootError> unregisteredRoots, @NotNull Collection<? extends VcsRootError> invalidRoots, boolean rootsAlreadyAdded) { String title; if (unregisteredRoots.isEmpty()) { title = VcsBundle.message("roots.notification.title.invalid.vcs.root.choice.mapping.mappings", invalidRoots.size()); } else if (invalidRoots.isEmpty()) { String vcs = getVcsName(unregisteredRoots); title = rootsAlreadyAdded ? VcsBundle.message("roots.notification.title.vcs.name.integration.enabled", vcs) : VcsBundle.message("notification.title.vcs.name.repository.repositories.found", vcs, unregisteredRoots.size()); } else { title = VcsBundle.message("roots.notification.title.vcs.root.configuration.problems"); } return title; } private static String getVcsName(Collection<? extends VcsRootError> roots) { String result = null; for (VcsRootError root : roots) { String vcsName = root.getMapping().getVcs(); if (result == null) { result = vcsName; } else if (!result.equals(vcsName)) { return VcsBundle.message("vcs.generic.name"); } } return result; } @NotNull private List<VcsRootError> <API key>(@NotNull Collection<? extends VcsRootError> errors) { return filter(errors, error -> { VcsDirectoryMapping mapping = error.getMapping(); return error.getType() == UNREGISTERED_ROOT && <API key>(mapping) && !<API key>(mapping) && !<API key>(mapping); }); } private boolean <API key>(Collection<? extends VcsRootError> allErrors) { return exists(allErrors, it -> it.getType() == UNREGISTERED_ROOT && <API key>(it.getMapping())); } @NotNull private static Collection<VcsRootError> getInvalidRoots(@NotNull Collection<? extends VcsRootError> errors) { return filter(errors, error -> error.getType() == VcsRootError.Type.EXTRA_MAPPING); } @VisibleForTesting @NotNull String <API key>(@NotNull VcsDirectoryMapping directoryMapping) { if (directoryMapping.isDefaultMapping()) return directoryMapping.toString(); return <API key>(directoryMapping.getDirectory()); } @VisibleForTesting @NotNull String <API key>(@NotNull String mapping) { String presentablePath = null; String projectDir = myProject.getBasePath(); if (projectDir != null && FileUtil.isAncestor(projectDir, mapping, true)) { String relativePath = FileUtil.getRelativePath(projectDir, mapping, '/'); if (relativePath != null) { presentablePath = <API key>(VcsBundle.message("label.relative.project.path.presentation", relativePath)); } } if (presentablePath == null) { presentablePath = FileUtil.<API key>(<API key>(mapping)); } return escapeXmlEntities(presentablePath); } }
## modification, are permitted provided that the following conditions are met: ## and/or other materials provided with the distribution. ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ## 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. import sys from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks from autobahn.twisted.wamp import ApplicationSession from autobahn.wamp.types import PublishOptions PASSWORDS = { u'peter': u'secret1', u'joe': u'secret2' } USER = u'peter' #USER = u'joe' class ClientSession(ApplicationSession): def onConnect(self): print("connected. joining realm {} as user {} ...".format(self.config.realm, USER)) self.join(self.config.realm, [u"wampcra"], USER) def onChallenge(self, challenge): print("authentication challenge received: {}".format(challenge)) if challenge.method == u"wampcra": if u'salt' in challenge.extra: key = auth.derive_key(PASSWORDS[USER].encode('utf8'), challenge.extra['salt'].encode('utf8'), challenge.extra.get('iterations', None), challenge.extra.get('keylen', None)) else: key = PASSWORDS[USER].encode('utf8') signature = auth.compute_wcs(key, challenge.extra['challenge'].encode('utf8')) return signature.decode('ascii') else: raise Exception("don't know how to compute challenge for authmethod {}".format(challenge.method)) @inlineCallbacks def onJoin(self, details): print("ok, session joined!") ## call a procedure we are allowed to call (so this should succeed) try: res = yield self.call(u'com.example.add2', 2, 3) print("call result: {}".format(res)) except Exception as e: print("call error: {}".format(e)) ## (try to) register a procedure where we are not allowed to (so this should fail) try: reg = yield self.register(lambda x, y: x * y, u'com.example.mul2') except Exception as e: print("registration failed - this is expected: {}".format(e)) ## publish to a couple of topics we are allowed to publish to. for topic in [ u'com.example.topic1', u'com.foobar.topic1']: try: yield self.publish(topic, "hello", options = PublishOptions(acknowledge = True)) print("ok, event published to topic {}".format(topic)) except Exception as e: print("publication to topic {} failed: {}".format(topic, e)) ## (try to) publish to a couple of topics we are not allowed to publish to (so this should fail) for topic in [ u'com.example.topic2', u'com.foobar.topic2']: try: yield self.publish(topic, "hello", options = PublishOptions(acknowledge = True)) print("ok, event published to topic {}".format(topic)) except Exception as e: print("publication to topic {} failed - this is expected: {}".format(topic, e)) self.leave() def onLeave(self, details): print("onLeave: {}".format(details)) self.disconnect() def onDisconnect(self): reactor.stop() if __name__ == '__main__': from autobahn.twisted.wamp import ApplicationRunner runner = ApplicationRunner(url = "ws://localhost:8080/ws", realm = "realm1") runner.run(ClientSession)
package io.lumify.core.util; import java.util.List; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; public class <API key> extends ThreadPoolExecutor { private LumifyLogger logger; private <API key> <API key>; private <API key><AtomicInteger> executionCount; private <API key><AtomicInteger> maxActive; private <API key><AtomicInteger> maxWaiting; public <API key>(LumifyLogger logger, int nThreads) { super(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); this.logger = logger; executionCount = new <API key><AtomicInteger>(16, AtomicInteger.class); maxActive = new <API key><AtomicInteger>(16, AtomicInteger.class); maxWaiting = new <API key><AtomicInteger>(16, AtomicInteger.class); <API key> = Executors.<API key>(); <API key>.scheduleAtFixedRate(new Runnable() { @Override public void run() { tick(); } }, 1, 1, TimeUnit.MINUTES); <API key>.scheduleAtFixedRate(new Runnable() { @Override public void run() { report(); } }, 1, 5, TimeUnit.MINUTES); } @Override protected void beforeExecute(Thread t, Runnable r) { super.beforeExecute(t, r); executionCount.head().incrementAndGet(); int active = getActiveCount(); int currentMaxActive = maxActive.head().get(); if (active > currentMaxActive) { maxActive.head().set(active); } int waiting = getQueue().size(); int currentMaxWaiting = maxWaiting.head().get(); if (waiting > currentMaxWaiting) { maxWaiting.head().set(waiting); } } @Override protected void afterExecute(Runnable r, Throwable t) { super.afterExecute(r, t); } public void tick() { executionCount.rotateForward(); executionCount.head().set(0); maxActive.rotateForward(); maxActive.head().set(0); maxWaiting.rotateForward(); maxWaiting.head().set(0); } public void report() { List<AtomicInteger> executionCountList = executionCount.readBackward(15); List<AtomicInteger> maxActiveList = maxActive.readBackward(15); List<AtomicInteger> maxWaitingList = maxWaiting.readBackward(15); report("executions: ", executionCountList); report("max active: ", maxActiveList); report("max waiting:", maxWaitingList); } private void report(String label, List<AtomicInteger> list) { int one = list.get(0).get(); int five = 0; int fifteen = 0; for (int i = 0; i < 15; i++) { int value = list.get(i).get(); if (i < 5) { five += value; } fifteen += value; } logger.debug("%s %3d / %6.2f / %6.2f", label, one, five / 5.0, fifteen / 15.0); } @Override public void shutdown() { <API key>.shutdown(); super.shutdown(); } @Override public boolean awaitTermination(long timeout, TimeUnit unit) throws <API key> { <API key>.awaitTermination(timeout, unit); return super.awaitTermination(timeout, unit); } @Override public List<Runnable> shutdownNow() { <API key>.shutdownNow(); return super.shutdownNow(); } }
class <API key> < ActiveRecord::Migration def change add_column :users, :hint_access, :boolean end end
#ifndef _MSC_RE_H_ #define _MSC_RE_H_ #define ABSOLUTE_VALUE 0 #define POSITIVE_VALUE 1 #define NEGATIVE_VALUE 2 typedef struct msre_engine msre_engine; typedef struct msre_ruleset msre_ruleset; typedef struct <API key> <API key>; typedef struct msre_rule msre_rule; typedef struct msre_var_metadata msre_var_metadata; typedef struct msre_var msre_var; typedef struct msre_op_metadata msre_op_metadata; typedef struct msre_tfn_metadata msre_tfn_metadata; typedef struct msre_actionset msre_actionset; typedef struct <API key> <API key>; typedef struct msre_action msre_action; typedef struct <API key> <API key>; typedef struct msre_cache_rec msre_cache_rec; #include "apr_general.h" #include "apr_tables.h" #include "modsecurity.h" #include "msc_pcre.h" #include "msc_tree.h" #include "persist_dbm.h" #include "apache2.h" #include "http_config.h" #if defined(WITH_LUA) #include "msc_lua.h" #endif /* Actions, variables, functions and operator functions */ char DSOLOCAL *<API key>(modsec_rec *msr, msre_ruleset *ruleset, msre_rule *rule, const char *p2, const char *p3); int DSOLOCAL <API key>(msre_rule *rule, rule_exception *re); char DSOLOCAL *<API key>(modsec_rec *msr, msre_ruleset *ruleset, rule_exception *re, const char *p2, const char *p3); char DSOLOCAL *<API key>(modsec_rec *msr, msre_ruleset *ruleset, rule_exception *re, apr_array_header_t *phase_arr, const char *p2, const char *p3); apr_status_t DSOLOCAL <API key>(modsec_rec *msr, const char *col_name, const msc_string *orig_var); int DSOLOCAL expand_macros(modsec_rec *msr, msc_string *var, msre_rule *rule, apr_pool_t *mptmp); msre_var_metadata DSOLOCAL *msre_resolve_var(msre_engine *engine, const char *name); msre_var DSOLOCAL *msre_create_var_ex(apr_pool_t *pool, msre_engine *engine, const char *name, const char *param, modsec_rec *msr, char **error_msg); int DSOLOCAL msre_parse_generic(apr_pool_t *pool, const char *text, apr_table_t *vartable, char **error_msg); int DSOLOCAL rule_id_in_range(int ruleid, const char *range); msre_var DSOLOCAL *generate_single_var(modsec_rec *msr, msre_var *var, apr_array_header_t *tfn_arr, msre_rule *rule, apr_pool_t *mptmp); #if defined(WITH_LUA) apr_table_t DSOLOCAL *generate_multi_var(modsec_rec *msr, msre_var *var, apr_array_header_t *tfn_arr, msre_rule *rule, apr_pool_t *mptmp); #endif /* Structures with the corresponding functions */ struct msre_engine { apr_pool_t *mp; apr_table_t *variables; apr_table_t *operators; apr_table_t *actions; apr_table_t *tfns; apr_table_t *reqbody_processors; }; msre_engine DSOLOCAL *msre_engine_create(apr_pool_t *parent_pool); void DSOLOCAL msre_engine_destroy(msre_engine *engine); msre_op_metadata DSOLOCAL *<API key>(msre_engine *engine, const char *name); struct msre_ruleset { apr_pool_t *mp; msre_engine *engine; apr_array_header_t *<API key>; apr_array_header_t *phase_request_body; apr_array_header_t *<API key>; apr_array_header_t *phase_response_body; apr_array_header_t *phase_logging; }; apr_status_t DSOLOCAL <API key>(msre_ruleset *ruleset, modsec_rec *msr); apr_status_t DSOLOCAL <API key>(msre_ruleset *ruleset, modsec_rec *msr); msre_ruleset DSOLOCAL *msre_ruleset_create(msre_engine *engine, apr_pool_t *mp); int DSOLOCAL <API key>(msre_ruleset *ruleset, msre_rule *rule, int phase); msre_rule DSOLOCAL *<API key>(msre_ruleset *ruleset, const char *id, int offset); int DSOLOCAL <API key>(msre_ruleset *ruleset, rule_exception *re); /* int DSOLOCAL <API key>(msre_ruleset *ruleset, rule_exception *re, apr_array_header_t *phase_arr); */ #define RULE_NO_MATCH 0 #define RULE_MATCH 1 #define RULE_PH_NONE 0 /* Not a placeholder */ #define RULE_PH_SKIPAFTER 1 /* Implicit placeholder for skipAfter */ #define RULE_PH_MARKER 2 /* Explicit placeholder for SecMarker */ #define RULE_TYPE_NORMAL 0 /* SecRule */ #define RULE_TYPE_ACTION 1 /* SecAction */ #define RULE_TYPE_MARKER 2 /* SecMarker */ #if defined(WITH_LUA) #define RULE_TYPE_LUA 3 /* SecRuleScript */ #endif struct msre_rule { apr_array_header_t *targets; const char *op_name; const char *op_param; void *op_param_data; msre_op_metadata *op_metadata; unsigned int op_negated; msre_actionset *actionset; const char *p1; const char *unparsed; const char *filename; int line_num; int placeholder; int type; msre_ruleset *ruleset; msre_rule *chain_starter; #if defined(<API key>) unsigned int execution_time; unsigned int trans_time; unsigned int op_time; #endif #if defined(WITH_LUA) /* Compiled Lua script. */ msc_script *script; #endif #if <API key> > 1 && <API key> > 0 ap_regex_t *sub_regex; #else regex_t *sub_regex; #endif char *sub_str; char *re_str; int re_precomp; int escape_re; TreeRoot *ip_op; }; char DSOLOCAL *<API key>(apr_pool_t *pool, const msre_rule *rule, const char *targets, const char *args, const char *actions); msre_rule DSOLOCAL *msre_rule_create(msre_ruleset *ruleset, int type, const char *fn, int line, const char *targets, const char *args, const char *actions, char **error_msg); #if defined(WITH_LUA) msre_rule DSOLOCAL *<API key>(msre_ruleset *ruleset, const char *fn, int line, const char *script_filename, const char *actions, char **error_msg); #endif #define VAR_SIMPLE 0 /* REQUEST_URI */ #define VAR_LIST 1 #define <API key> 1 #define PHASE_REQUEST_BODY 2 #define <API key> 3 #define PHASE_RESPONSE_BODY 4 #define PHASE_LOGGING 5 typedef int (*fn_op_param_init_t)(msre_rule *rule, char **error_msg); typedef int (*fn_op_execute_t)(modsec_rec *msr, msre_rule *rule, msre_var *var, char **error_msg); struct msre_op_metadata { const char *name; fn_op_param_init_t param_init; fn_op_execute_t execute; }; typedef int (*fn_tfn_execute_t)(apr_pool_t *pool, unsigned char *input, long int input_length, char **rval, long int *rval_length); struct msre_tfn_metadata { const char *name; /* Functions should populate *rval and return 1 on * success, or return -1 on failure (in which case *rval * should contain the error message. Strict functions * (those that validate in * addition to transforming) can return 0 when input * fails validation. Functions are free to perform * in-place transformation, or to allocate a new buffer * from the provideded temporary (per-rule) memory pool. * * NOTE Strict transformation functions not supported yet. */ fn_tfn_execute_t execute; }; void DSOLOCAL <API key>(msre_engine *engine, const char *name, fn_tfn_execute_t execute); void DSOLOCAL <API key>(msre_engine *engine, const char *name, fn_op_param_init_t fn1, fn_op_execute_t fn2); void DSOLOCAL <API key>(msre_engine *engine); void DSOLOCAL <API key>(msre_engine *engine); void DSOLOCAL <API key>(msre_engine *engine); void DSOLOCAL <API key>(msre_engine *engine); msre_tfn_metadata DSOLOCAL *<API key>(msre_engine *engine, const char *name); #define VAR_DONT_CACHE 0 #define VAR_CACHE 1 typedef char *(*fn_var_validate_t)(msre_ruleset *ruleset, msre_var *var); typedef int (*fn_var_generate_t)(modsec_rec *msr, msre_var *var, msre_rule *rule, apr_table_t *table, apr_pool_t *mptmp); struct msre_var_metadata { const char *name; unsigned int type; /* VAR_TYPE_ constants */ unsigned int argc_min; unsigned int argc_max; fn_var_validate_t validate; fn_var_generate_t generate; unsigned int is_cacheable; /* 0 - no, 1 - yes */ unsigned int availability; /* when does this variable become available? */ }; struct msre_var { char *name; const char *value; unsigned int value_len; char *param; const void *param_data; msre_var_metadata *metadata; msc_regex_t *param_regex; unsigned int is_negated; unsigned int is_counting; }; struct msre_actionset { apr_table_t *actions; /* Metadata */ const char *id; const char *rev; const char *msg; const char *logdata; const char *version; int maturity; int accuracy; int severity; int phase; msre_rule *rule; int arg_min; int arg_max; /* Flow */ int is_chained; int skip_count; const char *skip_after; /* Disruptive */ int intercept_action; const char *intercept_uri; int intercept_status; const char *intercept_pause; /* "block" needs parent action to reset it */ msre_action *<API key>; msre_action *<API key>; int <API key>; /* Other */ int log; int auditlog; int block; }; void DSOLOCAL <API key>(msre_engine *engine, const char *name, unsigned int type, unsigned int argc_min, unsigned int argc_max, fn_var_validate_t validate, fn_var_generate_t generate, unsigned int is_cacheable, unsigned int availability); msre_actionset DSOLOCAL *<API key>(msre_engine *engine, apr_pool_t *mp, const char *text, char **error_msg); msre_actionset DSOLOCAL *<API key>(msre_engine *engine, apr_pool_t *mp, msre_actionset *parent, msre_actionset *child, int inherit_by_default); msre_actionset DSOLOCAL *<API key>(msre_engine *engine); void DSOLOCAL <API key>(msre_actionset *actionset); void DSOLOCAL msre_actionset_init(msre_actionset *actionset, msre_rule *rule); typedef char *(*<API key>)(msre_engine *engine, apr_pool_t *mp, msre_action *action); typedef apr_status_t (*fn_action_init_t)(msre_engine *engine, apr_pool_t *mp, msre_actionset *actionset, msre_action *action); typedef apr_status_t (*fn_action_execute_t)(modsec_rec *msr, apr_pool_t *mptmp, msre_rule *rule, msre_action *action); #define ACTION_DISRUPTIVE 1 #define <API key> 2 #define ACTION_METADATA 3 #define ACTION_FLOW 4 #define NO_PLUS_MINUS 0 #define ALLOW_PLUS_MINUS 1 #define <API key> 1 #define <API key> 2 #define ACTION_CGROUP_NONE 0 #define <API key> 1 #define ACTION_CGROUP_LOG 2 #define <API key> 3 struct <API key> { const char *name; unsigned int type; unsigned int argc_min; unsigned int argc_max; unsigned int <API key>; unsigned int cardinality; unsigned int cardinality_group; <API key> validate; fn_action_init_t init; fn_action_execute_t execute; }; struct msre_action { <API key> *metadata; const char *param; const void *param_data; unsigned int param_plusminus; /* ABSOLUTE_VALUE, POSITIVE_VALUE, NEGATIVE_VALUE */ }; void DSOLOCAL <API key>(msre_engine *engine, const char *name, void *fn_init, void *fn_process, void *fn_complete); typedef int (*<API key>)(modsec_rec *msr, char **error_msg); typedef int (*<API key>)(modsec_rec *msr, const char *buf, unsigned int size, char **error_msg); typedef int (*<API key>)(modsec_rec *msr, char **error_msg); struct <API key> { const char *name; <API key> init; <API key> process; <API key> complete; }; msre_var_metadata DSOLOCAL *msre_resolve_var(msre_engine *engine, const char *name); int DSOLOCAL msre_parse_generic(apr_pool_t *pool, const char *text, apr_table_t *vartable, char **error_msg); apr_status_t DSOLOCAL msre_parse_vars(msre_ruleset *ruleset, const char *text, apr_array_header_t *arr, char **error_msg); char DSOLOCAL *<API key>(modsec_rec *msr, msre_actionset *actionset); /* -- Data Cache -- */ struct msre_cache_rec { int hits; int changed; int num; const char *path; const char *val; apr_size_t val_len; }; struct <API key> { const char *file; int threshold; }; #endif
=begin pod =TITLE role QuantHash =SUBTITLE Collection of objects represented as hash keys class QuantHash does Associative { } A C<QuantHash> represents a set of objects, represented as the keys of a C<Hash>. When asked to behave as a list it ignores its C<.values> and returns only C<.keys> (possibly replicated by weight in the case of bag types). For any C<QuantHash>, the C<.total> methods returns the current sum of the values. All standard QuantHash containers have a default value that is false (such as C<0> or C<''> or C<Nil> or C<Bool::False>), and keep around only those entries with non-default values, automatically deleting any entry if its value goes to that (false) default value. =end pod
// modification, are permitted provided that the following conditions are met: // documentation and/or other materials provided with the distribution. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // 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. package jodd.json.mock; public class Book extends Periodical { private String isbn; public Book(String isbn, String name) { super(name); this.isbn = isbn; } @Override public String getID() { return isbn; } @Override public void setID(String id) { isbn = id; } public void setID(Integer id) { isbn = Integer.toString(id); } public boolean isA() { return false; } public void setName(String name) { } }
# typed: strict # <API key>: true require "utils/git" require "utils/popen" # Extensions to {Pathname} for querying Git repository information. # @see Utils::Git # @api private module <API key> extend T::Sig sig { returns(T::Boolean) } def git? join(".git").exist? end # Gets the URL of the Git origin remote. sig { returns(T.nilable(String)) } def git_origin popen_git("config", "--get", "remote.origin.url") end # Sets the URL of the Git origin remote. sig { params(origin: String).returns(T.nilable(T::Boolean)) } def git_origin=(origin) return if !git? || !Utils::Git.available? safe_system Utils::Git.git, "remote", "set-url", "origin", origin, chdir: self end # Gets the full commit hash of the HEAD commit. sig { params(safe: T::Boolean).returns(T.nilable(String)) } def git_head(safe: false) popen_git("rev-parse", "--verify", "--quiet", "HEAD", safe: safe) end # Gets a short commit hash of the HEAD commit. sig { params(length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String)) } def git_short_head(length: nil, safe: false) short_arg = length.present? ? "--short=#{length}" : "--short" popen_git("rev-parse", short_arg, "--verify", "--quiet", "HEAD", safe: safe) end # Gets the relative date of the last commit, e.g. "1 hour ago" sig { returns(T.nilable(String)) } def git_last_commit popen_git("show", "-s", "--format=%cr", "HEAD") end # Gets the name of the currently checked-out branch, or HEAD if the repository is in a detached HEAD state. sig { params(safe: T::Boolean).returns(T.nilable(String)) } def git_branch(safe: false) popen_git("rev-parse", "--abbrev-ref", "HEAD", safe: safe) end # Change the name of a local branch sig { params(old: String, new: String).void } def git_rename_branch(old:, new:) popen_git("branch", "-m", old, new) end # Set an upstream branch for a local branch to track sig { params(local: String, origin: String).void } def <API key>(local:, origin:) popen_git("branch", "-u", "origin/#{origin}", local) end # Gets the name of the default origin HEAD branch. sig { returns(T.nilable(String)) } def git_origin_branch popen_git("symbolic-ref", "-q", "--short", "refs/remotes/origin/HEAD")&.split("/")&.last end # Returns true if the repository's current branch matches the default origin branch. sig { returns(T.nilable(T::Boolean)) } def <API key>? git_origin_branch == git_branch end # Returns the date of the last commit, in YYYY-MM-DD format. sig { returns(T.nilable(String)) } def <API key> popen_git("show", "-s", "--format=%cd", "--date=short", "HEAD") end # Returns true if the given branch exists on origin sig { params(branch: String).returns(T::Boolean) } def <API key>?(branch) popen_git("ls-remote", "--heads", "origin", branch).present? end sig { void } def <API key> popen_git("remote", "set-head", "origin", "--auto") end # Gets the full commit message of the specified commit, or of the HEAD commit if unspecified. sig { params(commit: String, safe: T::Boolean).returns(T.nilable(String)) } def git_commit_message(commit = "HEAD", safe: false) popen_git("log", "-1", "--pretty=%B", commit, "--", safe: safe, err: :out)&.strip end private sig { params(args: T.untyped, safe: T::Boolean, err: T.nilable(Symbol)).returns(T.nilable(String)) } def popen_git(*args, safe: false, err: nil) unless git? return unless safe raise "Not a Git repository: #{self}" end unless Utils::Git.available? return unless safe raise "Git is unavailable" end T.unsafe(Utils).popen_read(Utils::Git.git, *args, safe: safe, chdir: self, err: err).chomp.presence end end
cask 'cumulus' do version '0.10.1' sha256 '<SHA256-like>' # github.com/gillesdemey/Cumulus was verified as official when first introduced to the cask url "https://github.com/gillesdemey/Cumulus/releases/download/v#{version}/Cumulus-#{version}.dmg" appcast 'https://github.com/gillesdemey/Cumulus/releases.atom', checkpoint: '<SHA256-like>' name 'Cumulus' homepage 'https://gillesdemey.github.io/Cumulus/' app 'Cumulus.app' zap delete: [ '~/Library/Application Support/Cumulus', '~/Library/Caches/Cumulus', '~/Library/Preferences/com.gillesdemey.cumulus.plist', '~/Library/Saved Application State/com.gillesdemey.cumulus.savedState', ] end
class Latexml < Formula desc "LaTeX to XML/HTML/MathML Converter" homepage "https://dlmf.nist.gov/LaTeXML/" url "https://dlmf.nist.gov/LaTeXML/releases/LaTeXML-0.8.5.tar.gz" sha256 "<SHA256-like>" license :public_domain head "https://github.com/brucemiller/LaTeXML.git", branch: "master" livecheck do url "https://dlmf.nist.gov/LaTeXML/get.html" regex(/href=.*?LaTeXML[._-]v?(\d+(?:\.\d+)+)\.t/i) end bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "<SHA256-like>" sha256 cellar: :any_skip_relocation, big_sur: "<SHA256-like>" sha256 cellar: :any_skip_relocation, catalina: "<SHA256-like>" sha256 cellar: :any_skip_relocation, mojave: "<SHA256-like>" sha256 cellar: :any_skip_relocation, x86_64_linux: "<SHA256-like>" end uses_from_macos "libxml2" uses_from_macos "libxslt" uses_from_macos "perl" on_linux do depends_on "pkg-config" => :build end resource "Image::Size" do url "https://cpan.metacpan.org/authors/id/R/RJ/RJRAY/Image-Size-3.300.tar.gz" sha256 "<SHA256-like>" end resource "Text::Unidecode" do url "https://cpan.metacpan.org/authors/id/S/SB/SBURKE/Text-Unidecode-1.30.tar.gz" sha256 "<SHA256-like>" end resource "Path::Tiny" do on_linux do url "https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Path-Tiny-0.108.tar.gz" sha256 "<SHA256-like>" end end resource "IO::String" do on_linux do url "https://cpan.metacpan.org/authors/id/G/GA/GAAS/IO-String-1.08.tar.gz" sha256 "<SHA256-like>" end end resource "File::Chdir" do on_linux do url "https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/File-chdir-0.1010.tar.gz" sha256 "<SHA256-like>" end end resource "Capture::Tiny" do on_linux do url "https://cpan.metacpan.org/authors/id/D/DA/DAGOLDEN/Capture-Tiny-0.48.tar.gz" sha256 "<SHA256-like>" end end resource "File::Which" do on_linux do url "https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/File-Which-1.23.tar.gz" sha256 "<SHA256-like>" end end resource "Archive::Zip" do on_linux do url "https://cpan.metacpan.org/authors/id/P/PH/PHRED/Archive-Zip-1.64.tar.gz" sha256 "<SHA256-like>" end end resource "Alien::Build" do on_linux do url "https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/Alien-Build-1.78.tar.gz" sha256 "<SHA256-like>" end end resource "Alien::LibXML2" do on_linux do url "https://cpan.metacpan.org/authors/id/P/PL/PLICEASE/Alien-Libxml2-0.09.tar.gz" sha256 "<SHA256-like>" end end resource "LWP" do on_linux do url "https://cpan.metacpan.org/authors/id/O/OA/OALDERS/libwww-perl-6.39.tar.gz" sha256 "<SHA256-like>" end end resource "Parse::RecDescent" do on_linux do url "https://cpan.metacpan.org/authors/id/J/JT/JTBRAUN/Parse-RecDescent-1.967015.tar.gz" sha256 "<SHA256-like>" end end resource "XML::LibXML" do on_linux do url "https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/XML-LibXML-2.0201.tar.gz" sha256 "<SHA256-like>" end end resource "XML::Sax" do on_linux do url "https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-SAX-Base-1.09.tar.gz" sha256 "<SHA256-like>" end end resource "XML::LibXSLT" do on_linux do url "https://cpan.metacpan.org/authors/id/S/SH/SHLOMIF/XML-LibXSLT-1.96.tar.gz" sha256 "<SHA256-like>" end end resource "URI" do on_linux do url "https://cpan.metacpan.org/authors/id/O/OA/OALDERS/URI-1.76.tar.gz" sha256 "<SHA256-like>" end end resource "HTTP::Request" do on_linux do url "https://cpan.metacpan.org/authors/id/O/OA/OALDERS/HTTP-Message-6.18.tar.gz" sha256 "<SHA256-like>" end end resource "Canary::Stability" do on_linux do url "https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/<API key>.tar.gz" sha256 "<SHA256-like>" end end resource "JSON::XS" do on_linux do url "https://cpan.metacpan.org/authors/id/M/ML/MLEHMANN/JSON-XS-4.02.tar.gz" sha256 "<SHA256-like>" end end resource "Pod::Find" do on_linux do url "https://cpan.metacpan.org/authors/id/M/MA/MAREKR/Pod-Parser-1.63.tar.gz" sha256 "<SHA256-like>" end end resource "HTTP::Date" do on_linux do url "https://cpan.metacpan.org/authors/id/O/OA/OALDERS/HTTP-Date-6.05.tar.gz" sha256 "<SHA256-like>" end end resource "Try::Tiny" do on_linux do url "https://cpan.metacpan.org/authors/id/E/ET/ETHER/Try-Tiny-0.30.tar.gz" sha256 "<SHA256-like>" end end resource "Encode::Locale" do on_linux do url "https://cpan.metacpan.org/authors/id/G/GA/GAAS/Encode-Locale-1.05.tar.gz" sha256 "<SHA256-like>" end end def install ENV.prepend_create_path "PERL5LIB", libexec+"lib/perl5" resources.each do |r| r.stage do ENV["<API key>"] = "1" if OS.linux? system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}" system "make" system "make", "install" end end system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}" system "make", "install" doc.install "manual.pdf" (libexec+"bin").find.each do |path| next if path.directory? program = path.basename (bin+program).write_env_script("#{libexec}/bin/#{program}", PERL5LIB: ENV["PERL5LIB"]) end end test do (testpath/"test.tex").write <<~EOS \\documentclass{article} \\title{LaTeXML Homebrew Test} \\begin{document} \\maketitle \\end{document} EOS assert_match %r{<title>LaTeXML Homebrew Test</title>}, shell_output("#{bin}/latexml --quiet #{testpath}/test.tex") end end
cask 'miniconda' do version :latest sha256 :no_check url 'https://repo.continuum.io/miniconda/<API key>.sh' name 'Continuum Analytics Miniconda' homepage 'https: auto_updates true depends_on macos: '>= :lion' container type: :naked installer script: { executable: '<API key>.sh', args: ['-b'], } uninstall delete: '~/miniconda3' caveats do <API key> '~/miniconda3/bin' end end
#!/usr/bin/env python2.2 # Name: wxPyPlot.py # Purpose: # Created: 2003/11/03 # RCS-ID: $Id$ # Licence: Use as you wish. import wx import time, string # Needs Numeric try: import Numeric except: try: import numarray as Numeric #if numarray is used it is renamed Numeric except: raise ImportError, "Numeric or numarray not found. \n" + msg try: True except NameError: True = 1==1 False = 1==0 # Plotting classes... class PolyPoints: """Base Class for lines and markers - All methods are private. """ def __init__(self, points, attr): self.points = Numeric.array(points) self.currentScale= (1,1) self.currentShift= (0,0) self.scaled = self.points self.attributes = {} self.attributes.update(self._attributes) for name, value in attr.items(): if name not in self._attributes.keys(): raise KeyError, "Style attribute incorrect. Should be one of %s" %self._attributes.keys() self.attributes[name] = value def boundingBox(self): if len(self.points) == 0: #no curves to draw #defaults to (-1,-1) and (1,1) but axis can be set in Draw minXY= Numeric.array([-1,-1]) maxXY= Numeric.array([ 1, 1]) else: minXY= Numeric.minimum.reduce(self.points) maxXY= Numeric.maximum.reduce(self.points) return minXY, maxXY def scaleAndShift(self, scale=(1,1), shift=(0,0)): if len(self.points) == 0: #no curves to draw return if (scale is not self.currentScale) or (shift is not self.currentShift): #update point scaling self.scaled = scale*self.points+shift self.currentScale= scale self.currentShift= shift #else unchanged use the current scaling def getLegend(self): return self.attributes['legend'] class PolyLine(PolyPoints): """Class to define line type and style - All methods except __init__ are private. """ _attributes = {'colour': 'black', 'width': 1, 'style': wx.SOLID, 'legend': ''} def __init__(self, points, **attr): """Creates PolyLine object points - sequence (array, tuple or list) of (x,y) points making up line **attr - key word attributes Defaults: 'colour'= 'black', - wxPen Colour any wxNamedColour 'width'= 1, - Pen width 'style'= wxSOLID, - wxPen style 'legend'= '' - Line Legend to display """ PolyPoints.__init__(self, points, attr) def draw(self, dc, printerScale, coord= None): colour = self.attributes['colour'] width = self.attributes['width'] * printerScale style= self.attributes['style'] dc.SetPen(wx.Pen(wx.NamedColour(colour), int(width), style)) if coord == None: dc.DrawLines(self.scaled) else: dc.DrawLines(coord) #draw legend line def getSymExtent(self, printerScale): """Width and Height of Marker""" h= self.attributes['width'] * printerScale w= 5 * h return (w,h) class PolyMarker(PolyPoints): """Class to define marker type and style - All methods except __init__ are private. """ _attributes = {'colour': 'black', 'width': 1, 'size': 2, 'fillcolour': None, 'fillstyle': wx.SOLID, 'marker': 'circle', 'legend': ''} def __init__(self, points, **attr): """Creates PolyMarker object points - sequence (array, tuple or list) of (x,y) points **attr - key word attributes Defaults: 'colour'= 'black', - wxPen Colour any wxNamedColour 'width'= 1, - Pen width 'size'= 2, - Marker size 'fillcolour'= same as colour, - wxBrush Colour any wxNamedColour 'fillstyle'= wx.SOLID, - wxBrush fill style (use wxTRANSPARENT for no fill) 'marker'= 'circle' - Marker shape 'legend'= '' - Marker Legend to display Marker Shapes: - 'circle' - 'dot' - 'square' - 'triangle' - 'triangle_down' - 'cross' - 'plus' """ PolyPoints.__init__(self, points, attr) def draw(self, dc, printerScale, coord= None): colour = self.attributes['colour'] width = self.attributes['width'] * printerScale size = self.attributes['size'] * printerScale fillcolour = self.attributes['fillcolour'] fillstyle = self.attributes['fillstyle'] marker = self.attributes['marker'] dc.SetPen(wx.Pen(wx.NamedColour(colour),int(width))) if fillcolour: dc.SetBrush(wx.Brush(wx.NamedColour(fillcolour),fillstyle)) else: dc.SetBrush(wx.Brush(wx.NamedColour(colour), fillstyle)) if coord == None: self._drawmarkers(dc, self.scaled, marker, size) else: self._drawmarkers(dc, coord, marker, size) #draw legend marker def getSymExtent(self, printerScale): """Width and Height of Marker""" s= 5*self.attributes['size'] * printerScale return (s,s) def _drawmarkers(self, dc, coords, marker,size=1): f = eval('self._' +marker) f(dc, coords, size) def _circle(self, dc, coords, size=1): fact= 2.5*size wh= 5.0*size rect= Numeric.zeros((len(coords),4),Numeric.Float)+[0.0,0.0,wh,wh] rect[:,0:2]= coords-[fact,fact] dc.DrawEllipseList(rect.astype(Numeric.Int32)) def _dot(self, dc, coords, size=1): dc.DrawPointList(coords) def _square(self, dc, coords, size=1): fact= 2.5*size wh= 5.0*size rect= Numeric.zeros((len(coords),4),Numeric.Float)+[0.0,0.0,wh,wh] rect[:,0:2]= coords-[fact,fact] dc.DrawRectangleList(rect.astype(Numeric.Int32)) def _triangle(self, dc, coords, size=1): shape= [(-2.5*size,1.44*size), (2.5*size,1.44*size), (0.0,-2.88*size)] poly= Numeric.repeat(coords,3) poly.shape= (len(coords),3,2) poly += shape dc.DrawPolygonList(poly.astype(Numeric.Int32)) def _triangle_down(self, dc, coords, size=1): shape= [(-2.5*size,-1.44*size), (2.5*size,-1.44*size), (0.0,2.88*size)] poly= Numeric.repeat(coords,3) poly.shape= (len(coords),3,2) poly += shape dc.DrawPolygonList(poly.astype(Numeric.Int32)) def _cross(self, dc, coords, size=1): fact= 2.5*size for f in [[-fact,-fact,fact,fact],[-fact,fact,fact,-fact]]: lines= Numeric.concatenate((coords,coords),axis=1)+f dc.DrawLineList(lines.astype(Numeric.Int32)) def _plus(self, dc, coords, size=1): fact= 2.5*size for f in [[-fact,0,fact,0],[0,-fact,0,fact]]: lines= Numeric.concatenate((coords,coords),axis=1)+f dc.DrawLineList(lines.astype(Numeric.Int32)) class PlotGraphics: """Container to hold PolyXXX objects and graph labels - All methods except __init__ are private. """ def __init__(self, objects, title='', xLabel='', yLabel= ''): """Creates PlotGraphics object objects - list of PolyXXX objects to make graph title - title shown at top of graph xLabel - label shown on x-axis yLabel - label shown on y-axis """ if type(objects) not in [list,tuple]: raise TypeError, "objects argument should be list or tuple" self.objects = objects self.title= title self.xLabel= xLabel self.yLabel= yLabel def boundingBox(self): p1, p2 = self.objects[0].boundingBox() for o in self.objects[1:]: p1o, p2o = o.boundingBox() p1 = Numeric.minimum(p1, p1o) p2 = Numeric.maximum(p2, p2o) return p1, p2 def scaleAndShift(self, scale=(1,1), shift=(0,0)): for o in self.objects: o.scaleAndShift(scale, shift) def setPrinterScale(self, scale): """Thickens up lines and markers only for printing""" self.printerScale= scale def setXLabel(self, xLabel= ''): """Set the X axis label on the graph""" self.xLabel= xLabel def setYLabel(self, yLabel= ''): """Set the Y axis label on the graph""" self.yLabel= yLabel def setTitle(self, title= ''): """Set the title at the top of graph""" self.title= title def getXLabel(self): """Get x axis label string""" return self.xLabel def getYLabel(self): """Get y axis label string""" return self.yLabel def getTitle(self, title= ''): """Get the title at the top of graph""" return self.title def draw(self, dc): for o in self.objects: #t=time.clock() #profile info o.draw(dc, self.printerScale) #dt= time.clock()-t #print o, "time=", dt def getSymExtent(self, printerScale): """Get max width and height of lines and markers symbols for legend""" symExt = self.objects[0].getSymExtent(printerScale) for o in self.objects[1:]: oSymExt = o.getSymExtent(printerScale) symExt = Numeric.maximum(symExt, oSymExt) return symExt def getLegendNames(self): """Returns list of legend names""" lst = [None]*len(self) for i in range(len(self)): lst[i]= self.objects[i].getLegend() return lst def __len__(self): return len(self.objects) def __getitem__(self, item): return self.objects[item] #Main window that you will want to import into your application. class PlotCanvas(wx.Window): """Subclass of a wxWindow to allow simple general plotting of data with zoom, labels, and automatic axis scaling.""" def __init__(self, parent, id = -1, pos=wx.DefaultPosition, size=wx.DefaultSize, style= wx.DEFAULT_FRAME_STYLE, name= ""): """Constucts a window, which can be a child of a frame, dialog or any other non-control window""" wx.Window.__init__(self, parent, id, pos, size, style, name) self.border = (1,1) self.SetBackgroundColour(wx.NamedColour("white")) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self,self.OnSize) #Create some mouse events for zooming wx.EVT_LEFT_DOWN(self, self.OnMouseLeftDown) wx.EVT_LEFT_UP(self, self.OnMouseLeftUp) wx.EVT_MOTION(self, self.OnMotion) wx.EVT_LEFT_DCLICK(self, self.OnMouseDoubleClick) wx.EVT_RIGHT_DOWN(self, self.OnMouseRightDown) # set curser as cross-hairs self.SetCursor(wx.CROSS_CURSOR) #Things for printing self.print_data = wx.PrintData() self.print_data.SetPaperId(wx.PAPER_LETTER) self.print_data.SetOrientation(wx.LANDSCAPE) self.pageSetupData= wx.PageSetupDialogData() self.pageSetupData.<API key>((25,25)) self.pageSetupData.SetMarginTopLeft((25,25)) self.pageSetupData.SetPrintData(self.print_data) self.printerScale = 1 self.parent= parent #Zooming variables self._zoomInFactor = 0.5 self._zoomOutFactor = 2 self._zoomCorner1= Numeric.array([0.0, 0.0]) #left mouse down corner self._zoomCorner2= Numeric.array([0.0, 0.0]) #left mouse up corner self._zoomEnabled= False self._hasDragged= False #Drawing Variables self.last_draw = None self._pointScale= 1 self._pointShift= 0 self._xSpec= 'auto' self._ySpec= 'auto' self._gridEnabled= False self._legendEnabled= False #Fonts self._fontCache = {} self._fontSizeAxis= 10 self._fontSizeTitle= 15 self._fontSizeLegend= 7 # OnSize called to make sure the buffer is initialized. # This might result in OnSize getting called twice on some # platforms at initialization, but little harm done. self.OnSize(None) #sets the initial size based on client size #SaveFile wx.<API key>() def SaveFile(self, fileName= ''): """Saves the file to the type specified in the extension. If no file name is specified a dialog box is provided. Returns True if sucessful, otherwise False. .bmp Save a Windows bitmap file. .xbm Save an X bitmap file. .xpm Save an XPM bitmap file. .png Save a Portable Network Graphics file. .jpg Save a Joint Photographic Experts Group file. """ if string.lower(fileName[-3:]) not in ['bmp','xbm','xpm','png','jpg']: dlg1 = wx.FileDialog(self, "Choose a file with extension bmp, gif, xbm, xpm, png, or jpg", ".", "", "BMP files (*.bmp)|*.bmp|XBM files (*.xbm)|*.xbm|XPM file (*.xpm)|*.xpm|PNG files (*.png)|*.png|JPG files (*.jpg)|*.jpg", wx.SAVE|wx.OVERWRITE_PROMPT) try: while 1: if dlg1.ShowModal() == wx.ID_OK: fileName = dlg1.GetPath() #Check for proper exension if string.lower(fileName[-3:]) not in ['bmp','xbm','xpm','png','jpg']: dlg2 = wx.MessageDialog(self, 'File name extension\n' 'must be one of\n' 'bmp, xbm, xpm, png, or jpg', 'File Name Error', wx.OK | wx.ICON_ERROR) try: dlg2.ShowModal() finally: dlg2.Destroy() else: break #now save file else: #exit without saving return False finally: dlg1.Destroy() #File name has required extension fType = string.lower(fileName[-3:]) if fType == "bmp": tp= wx.BITMAP_TYPE_BMP #Save a Windows bitmap file. elif fType == "xbm": tp= wx.BITMAP_TYPE_XBM #Save an X bitmap file. elif fType == "xpm": tp= wx.BITMAP_TYPE_XPM #Save an XPM bitmap file. elif fType == "jpg": tp= wx.BITMAP_TYPE_JPEG #Save a JPG file. else: tp= wx.BITMAP_TYPE_PNG #Save a PNG file. #Save Bitmap res= self._Buffer.SaveFile(fileName, tp) return res def PageSetup(self): """Brings up the page setup dialog""" data = self.pageSetupData data.SetPrintData(self.print_data) dlg = wx.PageSetupDialog(self.parent, data) try: if dlg.ShowModal() == wx.ID_OK: data = dlg.GetPageSetupData() #returns <API key> #updates page parameters from dialog self.pageSetupData.<API key>(data.<API key>()) self.pageSetupData.SetMarginTopLeft(data.GetMarginTopLeft()) self.pageSetupData.SetPrintData(data.GetPrintData()) self.print_data=data.GetPrintData() #updates print_data finally: dlg.Destroy() def Printout(self, paper=None): """Print current plot.""" if paper != None: self.print_data.SetPaperId(paper) pdd = wx.PrintDialogData() pdd.SetPrintData(self.print_data) printer = wx.Printer(pdd) out = plot_printout(self) print_ok = printer.Print(self.parent, out) if print_ok: self.print_data = printer.GetPrintDialogData().GetPrintData() out.Destroy() def PrintPreview(self): """Print-preview current plot.""" printout = plot_printout(self) printout2 = plot_printout(self) self.preview = wx.PrintPreview(printout, printout2, self.print_data) if not self.preview.Ok(): wx.MessageDialog(self, "Print Preview failed.\n" \ "Check that default printer is configured\n", \ "Print error", wx.OK|wx.CENTRE).ShowModal() self.preview.SetZoom(30) #search up tree to find frame instance frameInst= self while not isinstance(frameInst, wx.Frame): frameInst= frameInst.GetParent() frame = wx.PreviewFrame(self.preview, frameInst, "Preview") frame.Initialize() frame.SetPosition(self.GetPosition()) frame.SetSize((500,400)) frame.Centre(wx.BOTH) frame.Show(True) def SetFontSizeAxis(self, point= 10): """Set the tick and axis label font size (default is 10 point)""" self._fontSizeAxis= point def GetFontSizeAxis(self): """Get current tick and axis label font size in points""" return self._fontSizeAxis def SetFontSizeTitle(self, point= 15): """Set Title font size (default is 15 point)""" self._fontSizeTitle= point def GetFontSizeTitle(self): """Get current Title font size in points""" return self._fontSizeTitle def SetFontSizeLegend(self, point= 7): """Set Legend font size (default is 7 point)""" self._fontSizeLegend= point def GetFontSizeLegend(self): """Get current Legend font size in points""" return self._fontSizeLegend def SetEnableZoom(self, value): """Set True to enable zooming.""" if value not in [True,False]: raise TypeError, "Value should be True or False" self._zoomEnabled= value def GetEnableZoom(self): """True if zooming enabled.""" return self._zoomEnabled def SetEnableGrid(self, value): """Set True to enable grid.""" if value not in [True,False]: raise TypeError, "Value should be True or False" self._gridEnabled= value self.Redraw() def GetEnableGrid(self): """True if grid enabled.""" return self._gridEnabled def SetEnableLegend(self, value): """Set True to enable legend.""" if value not in [True,False]: raise TypeError, "Value should be True or False" self._legendEnabled= value self.Redraw() def GetEnableLegend(self): """True if Legend enabled.""" return self._legendEnabled def Reset(self): """Unzoom the plot.""" if self.last_draw is not None: self.Draw(self.last_draw[0]) def ScrollRight(self, units): """Move view right number of axis units.""" if self.last_draw is not None: graphics, xAxis, yAxis= self.last_draw xAxis= (xAxis[0]+units, xAxis[1]+units) self.Draw(graphics,xAxis,yAxis) def ScrollUp(self, units): """Move view up number of axis units.""" if self.last_draw is not None: graphics, xAxis, yAxis= self.last_draw yAxis= (yAxis[0]+units, yAxis[1]+units) self.Draw(graphics,xAxis,yAxis) def GetXY(self,event): """Takes a mouse event and returns the XY user axis values.""" screenPos= Numeric.array( event.GetPosition()) x,y= (screenPos-self._pointShift)/self._pointScale return x,y def SetXSpec(self, type= 'auto'): """xSpec- defines x axis type. Can be 'none', 'min' or 'auto' where: 'none' - shows no axis or tick mark values 'min' - shows min bounding box values 'auto' - rounds axis range to sensible values """ self._xSpec= type def SetYSpec(self, type= 'auto'): """ySpec- defines x axis type. Can be 'none', 'min' or 'auto' where: 'none' - shows no axis or tick mark values 'min' - shows min bounding box values 'auto' - rounds axis range to sensible values """ self._ySpec= type def GetXSpec(self): """Returns current XSpec for axis""" return self._xSpec def GetYSpec(self): """Returns current YSpec for axis""" return self._ySpec def GetXMaxRange(self): """Returns (minX, maxX) x-axis range for displayed graph""" graphics= self.last_draw[0] p1, p2 = graphics.boundingBox() #min, max points of graphics xAxis = self._axisInterval(self._xSpec, p1[0], p2[0]) #in user units return xAxis def GetYMaxRange(self): """Returns (minY, maxY) y-axis range for displayed graph""" graphics= self.last_draw[0] p1, p2 = graphics.boundingBox() #min, max points of graphics yAxis = self._axisInterval(self._ySpec, p1[1], p2[1]) return yAxis def GetXCurrentRange(self): """Returns (minX, maxX) x-axis for currently displayed portion of graph""" return self.last_draw[1] def GetYCurrentRange(self): """Returns (minY, maxY) y-axis for currently displayed portion of graph""" return self.last_draw[2] def Draw(self, graphics, xAxis = None, yAxis = None, dc = None): """Draw objects in graphics with specified x and y axis. graphics- instance of PlotGraphics with list of PolyXXX objects xAxis - tuple with (min, max) axis range to view yAxis - same as xAxis dc - drawing context - doesn't have to be specified. If it's not, the offscreen buffer is used """ #check Axis is either tuple or none if type(xAxis) not in [type(None),tuple]: raise TypeError, "xAxis should be None or (minX,maxX)" if type(yAxis) not in [type(None),tuple]: raise TypeError, "yAxis should be None or (minY,maxY)" #check case for axis = (a,b) where a==b caused by improper zooms if xAxis != None: if xAxis[0] == xAxis[1]: return if yAxis != None: if yAxis[0] == yAxis[1]: return if dc == None: # allows using floats for certain functions dc = FloatDCWrapper(wx.BufferedDC(wx.ClientDC(self), self._Buffer)) dc.Clear() dc.BeginDrawing() #dc.Clear() #set font size for every thing but title and legend dc.SetFont(self._getFont(self._fontSizeAxis)) #sizes axis to axis type, create lower left and upper right corners of plot if xAxis == None or yAxis == None: #One or both axis not specified in Draw p1, p2 = graphics.boundingBox() #min, max points of graphics if xAxis == None: xAxis = self._axisInterval(self._xSpec, p1[0], p2[0]) #in user units if yAxis == None: yAxis = self._axisInterval(self._ySpec, p1[1], p2[1]) #Adjust bounding box for axis spec p1[0],p1[1] = xAxis[0], yAxis[0] #lower left corner user scale (xmin,ymin) p2[0],p2[1] = xAxis[1], yAxis[1] #upper right corner user scale (xmax,ymax) else: #Both axis specified in Draw p1= Numeric.array([xAxis[0], yAxis[0]]) #lower left corner user scale (xmin,ymin) p2= Numeric.array([xAxis[1], yAxis[1]]) #upper right corner user scale (xmax,ymax) self.last_draw = (graphics, xAxis, yAxis) #saves most recient values #Get ticks and textExtents for axis if required if self._xSpec is not 'none': xticks = self._ticks(xAxis[0], xAxis[1]) xTextExtent = dc.GetTextExtent(xticks[-1][1])#w h of x axis text last number on axis else: xticks = None xTextExtent= (0,0) #No text for ticks if self._ySpec is not 'none': yticks = self._ticks(yAxis[0], yAxis[1]) yTextExtentBottom= dc.GetTextExtent(yticks[0][1]) yTextExtentTop = dc.GetTextExtent(yticks[-1][1]) yTextExtent= (max(yTextExtentBottom[0],yTextExtentTop[0]), max(yTextExtentBottom[1],yTextExtentTop[1])) else: yticks = None yTextExtent= (0,0) #No text for ticks #TextExtents for Title and Axis Labels titleWH, xLabelWH, yLabelWH= self._titleLablesWH(dc, graphics) #TextExtents for Legend legendBoxWH, legendSymExt, legendTextExt = self._legendWH(dc, graphics) #room around graph area rhsW= max(xTextExtent[0], legendBoxWH[0]) #use larger of number width or legend width lhsW= yTextExtent[0]+ yLabelWH[1] bottomH= max(xTextExtent[1], yTextExtent[1]/2.)+ xLabelWH[1] topH= yTextExtent[1]/2. + titleWH[1] textSize_scale= Numeric.array([rhsW+lhsW,bottomH+topH]) #make plot area smaller by text size textSize_shift= Numeric.array([lhsW, bottomH]) #shift plot area by this amount #drawing title and labels text dc.SetFont(self._getFont(self._fontSizeTitle)) titlePos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- titleWH[0]/2., self.plotbox_origin[1]- self.plotbox_size[1]) dc.DrawText(graphics.getTitle(),titlePos[0],titlePos[1]) dc.SetFont(self._getFont(self._fontSizeAxis)) xLabelPos= (self.plotbox_origin[0]+ lhsW + (self.plotbox_size[0]-lhsW-rhsW)/2.- xLabelWH[0]/2., self.plotbox_origin[1]- xLabelWH[1]) dc.DrawText(graphics.getXLabel(),xLabelPos[0],xLabelPos[1]) yLabelPos= (self.plotbox_origin[0], self.plotbox_origin[1]- bottomH- (self.plotbox_size[1]-bottomH-topH)/2.+ yLabelWH[0]/2.) if graphics.getYLabel(): #bug fix for Linux dc.DrawRotatedText(graphics.getYLabel(),yLabelPos[0],yLabelPos[1],90) #drawing legend makers and text if self._legendEnabled: self._drawLegend(dc,graphics,rhsW,topH,legendBoxWH, legendSymExt, legendTextExt) #allow for scaling and shifting plotted points scale = (self.<API key>) / (p2-p1)* Numeric.array((1,-1)) shift = -p1*scale + self.plotbox_origin + textSize_shift * Numeric.array((1,-1)) self._pointScale= scale #make available for mouse events self._pointShift= shift self._drawAxes(dc, p1, p2, scale, shift, xticks, yticks) graphics.scaleAndShift(scale, shift) graphics.setPrinterScale(self.printerScale) #thicken up lines and markers if printing #set clipping area so drawing does not occur outside axis box ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(p1, p2) dc.SetClippingRegion(ptx,pty,rectWidth,rectHeight) #Draw the lines and markers #start = time.clock() graphics.draw(dc) #print "entire graphics drawing took: %f second"%(time.clock() - start) #remove the clipping region dc.<API key>() dc.EndDrawing() def Redraw(self, dc= None): """Redraw the existing plot.""" if self.last_draw is not None: graphics, xAxis, yAxis= self.last_draw self.Draw(graphics,xAxis,yAxis,dc) def Clear(self): """Erase the window.""" dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer) dc.Clear() self.last_draw = None def Zoom(self, Center, Ratio): """ Zoom on the plot Centers on the X,Y coords given in Center Zooms by the Ratio = (Xratio, Yratio) given """ x,y = Center if self.last_draw != None: (graphics, xAxis, yAxis) = self.last_draw w = (xAxis[1] - xAxis[0]) * Ratio[0] h = (yAxis[1] - yAxis[0]) * Ratio[1] xAxis = ( x - w/2, x + w/2 ) yAxis = ( y - h/2, y + h/2 ) self.Draw(graphics, xAxis, yAxis) def OnMotion(self, event): if self._zoomEnabled and event.LeftIsDown(): if self._hasDragged: self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) #remove old else: self._hasDragged= True self._zoomCorner2[0], self._zoomCorner2[1] = self.GetXY(event) self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) #add new def OnMouseLeftDown(self,event): self._zoomCorner1[0], self._zoomCorner1[1]= self.GetXY(event) def OnMouseLeftUp(self, event): if self._zoomEnabled: if self._hasDragged == True: self._drawRubberBand(self._zoomCorner1, self._zoomCorner2) #remove old self._zoomCorner2[0], self._zoomCorner2[1]= self.GetXY(event) self._hasDragged = False #reset flag minX, minY= Numeric.minimum( self._zoomCorner1, self._zoomCorner2) maxX, maxY= Numeric.maximum( self._zoomCorner1, self._zoomCorner2) if self.last_draw != None: self.Draw(self.last_draw[0], xAxis = (minX,maxX), yAxis = (minY,maxY), dc = None) #else: # A box has not been drawn, zoom in on a point ## this interfered with the double click, so I've disables it. # X,Y = self.GetXY(event) # self.Zoom( (X,Y), (self._zoomInFactor,self._zoomInFactor) ) def OnMouseDoubleClick(self,event): if self._zoomEnabled: self.Reset() def OnMouseRightDown(self,event): if self._zoomEnabled: X,Y = self.GetXY(event) self.Zoom( (X,Y), (self._zoomOutFactor, self._zoomOutFactor) ) def OnPaint(self, event): # All that is needed here is to draw the buffer to screen dc = wx.BufferedPaintDC(self, self._Buffer) def OnSize(self,event): # The Buffer init is done here, to make sure the buffer is always # the same size as the Window Size = self.GetClientSizeTuple() # Make new offscreen bitmap: this bitmap will always have the # current drawing in it, so it can be used to save the image to # a file, or whatever. self._Buffer = wx.EmptyBitmap(Size[0],Size[1]) self._setSize() if self.last_draw is None: self.Clear() else: graphics, xSpec, ySpec = self.last_draw self.Draw(graphics,xSpec,ySpec) def _setSize(self, width=None, height=None): """DC width and height.""" if width == None: (self.width,self.height) = self.GetClientSizeTuple() else: self.width, self.height= width,height self.plotbox_size = 0.97*Numeric.array([self.width, self.height]) xo = 0.5*(self.width-self.plotbox_size[0]) yo = self.height-0.5*(self.height-self.plotbox_size[1]) self.plotbox_origin = Numeric.array([xo, yo]) def _setPrinterScale(self, scale): """Used to thicken lines and increase marker size for print out.""" #line thickness on printer is very thin at 600 dot/in. Markers small self.printerScale= scale def _printDraw(self, printDC): """Used for printing.""" if self.last_draw != None: graphics, xSpec, ySpec= self.last_draw self.Draw(graphics,xSpec,ySpec,printDC) def _drawLegend(self,dc,graphics,rhsW,topH,legendBoxWH, legendSymExt, legendTextExt): """Draws legend symbols and text""" #top right hand corner of graph box is ref corner trhc= self.plotbox_origin+ (self.plotbox_size-[rhsW,topH])*[1,-1] legendLHS= .091* legendBoxWH[0] #border space between legend sym and graph box lineHeight= max(legendSymExt[1], legendTextExt[1]) * 1.1 #1.1 used as space between lines dc.SetFont(self._getFont(self._fontSizeLegend)) for i in range(len(graphics)): o = graphics[i] s= i*lineHeight if isinstance(o,PolyMarker): #draw marker with legend pnt= (trhc[0]+legendLHS+legendSymExt[0]/2., trhc[1]+s+lineHeight/2.) o.draw(dc, self.printerScale, coord= Numeric.array([pnt])) elif isinstance(o,PolyLine): #draw line with legend pnt1= (trhc[0]+legendLHS, trhc[1]+s+lineHeight/2.) pnt2= (trhc[0]+legendLHS+legendSymExt[0], trhc[1]+s+lineHeight/2.) o.draw(dc, self.printerScale, coord= Numeric.array([pnt1,pnt2])) else: raise TypeError, "object is neither PolyMarker or PolyLine instance" #draw legend txt pnt= (trhc[0]+legendLHS+legendSymExt[0], trhc[1]+s+lineHeight/2.-legendTextExt[1]/2) dc.DrawText(o.getLegend(),pnt[0],pnt[1]) dc.SetFont(self._getFont(self._fontSizeAxis)) #reset def _titleLablesWH(self, dc, graphics): """Draws Title and labels and returns width and height for each""" #TextExtents for Title and Axis Labels dc.SetFont(self._getFont(self._fontSizeTitle)) title= graphics.getTitle() titleWH= dc.GetTextExtent(title) dc.SetFont(self._getFont(self._fontSizeAxis)) xLabel, yLabel= graphics.getXLabel(),graphics.getYLabel() xLabelWH= dc.GetTextExtent(xLabel) yLabelWH= dc.GetTextExtent(yLabel) return titleWH, xLabelWH, yLabelWH def _legendWH(self, dc, graphics): """Returns the size in screen units for legend box""" if self._legendEnabled != True: legendBoxWH= symExt= txtExt= (0,0) else: #find max symbol size symExt= graphics.getSymExtent(self.printerScale) #find max legend text extent dc.SetFont(self._getFont(self._fontSizeLegend)) txtList= graphics.getLegendNames() txtExt= dc.GetTextExtent(txtList[0]) for txt in graphics.getLegendNames()[1:]: txtExt= Numeric.maximum(txtExt,dc.GetTextExtent(txt)) maxW= symExt[0]+txtExt[0] maxH= max(symExt[1],txtExt[1]) #padding .1 for lhs of legend box and space between lines maxW= maxW* 1.1 maxH= maxH* 1.1 * len(txtList) dc.SetFont(self._getFont(self._fontSizeAxis)) legendBoxWH= (maxW,maxH) return (legendBoxWH, symExt, txtExt) def _drawRubberBand(self, corner1, corner2): """Draws/erases rect box from corner1 to corner2""" ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(corner1, corner2) #draw rectangle dc = wx.ClientDC( self ) dc.BeginDrawing() dc.SetPen(wx.Pen(wx.BLACK)) dc.SetBrush(wx.Brush( wx.WHITE, wx.TRANSPARENT ) ) dc.SetLogicalFunction(wx.INVERT) dc.DrawRectangle( ptx,pty,rectWidth,rectHeight) dc.SetLogicalFunction(wx.COPY) dc.EndDrawing() def _getFont(self,size): """Take font size, adjusts if printing and returns wxFont""" s = size*self.printerScale of = self.GetFont() #Linux speed up to get font from cache rather than X font server key = (int(s), of.GetFamily (), of.GetStyle (), of.GetWeight ()) font = self._fontCache.get (key, None) if font: return font # yeah! cache hit else: font = wx.Font(int(s), of.GetFamily(), of.GetStyle(), of.GetWeight()) self._fontCache[key] = font return font def _point2ClientCoord(self, corner1, corner2): """Converts user point coords to client screen int coords x,y,width,height""" c1= Numeric.array(corner1) c2= Numeric.array(corner2) #convert to screen coords pt1= c1*self._pointScale+self._pointShift pt2= c2*self._pointScale+self._pointShift #make height and width positive pul= Numeric.minimum(pt1,pt2) #Upper left corner plr= Numeric.maximum(pt1,pt2) #Lower right corner rectWidth, rectHeight= plr-pul ptx,pty= pul return int(ptx),int(pty),int(rectWidth),int(rectHeight) #return ints def _axisInterval(self, spec, lower, upper): """Returns sensible axis range for given spec""" if spec == 'none' or spec == 'min': if lower == upper: return lower-0.5, upper+0.5 else: return lower, upper elif spec == 'auto': range = upper-lower if range == 0.: return lower-0.5, upper+0.5 log = Numeric.log10(range) power = Numeric.floor(log) fraction = log-power if fraction <= 0.05: power = power-1 grid = 10.**power lower = lower - lower % grid mod = upper % grid if mod != 0: upper = upper - mod + grid return lower, upper elif type(spec) == type(()): lower, upper = spec if lower <= upper: return lower, upper else: return upper, lower else: raise ValueError, str(spec) + ': illegal axis specification' def _drawAxes(self, dc, p1, p2, scale, shift, xticks, yticks): penWidth= self.printerScale #increases thickness for printing only dc.SetPen(wx.Pen(wx.NamedColour('BLACK'),int(penWidth))) #set length of tick marks--long ones make grid if self._gridEnabled: x,y,width,height= self._point2ClientCoord(p1,p2) yTickLength= width/2.0 +1 xTickLength= height/2.0 +1 else: yTickLength= 3 * self.printerScale #lengthens lines for printing xTickLength= 3 * self.printerScale if self._xSpec is not 'none': lower, upper = p1[0],p2[0] text = 1 for y, d in [(p1[1], -xTickLength), (p2[1], xTickLength)]: #miny, maxy and tick lengths a1 = scale*Numeric.array([lower, y])+shift a2 = scale*Numeric.array([upper, y])+shift dc.DrawLine(a1[0],a1[1],a2[0],a2[1]) #draws upper and lower axis line for x, label in xticks: pt = scale*Numeric.array([x, y])+shift dc.DrawLine(pt[0],pt[1],pt[0],pt[1] + d) #draws tick mark d units if text: dc.DrawText(label,pt[0],pt[1]) text = 0 #axis values not drawn on top side if self._ySpec is not 'none': lower, upper = p1[1],p2[1] text = 1 h = dc.GetCharHeight() for x, d in [(p1[0], -yTickLength), (p2[0], yTickLength)]: a1 = scale*Numeric.array([x, lower])+shift a2 = scale*Numeric.array([x, upper])+shift dc.DrawLine(a1[0],a1[1],a2[0],a2[1]) for y, label in yticks: pt = scale*Numeric.array([x, y])+shift dc.DrawLine(pt[0],pt[1],pt[0]-d,pt[1]) if text: dc.DrawText(label,pt[0]-dc.GetTextExtent(label)[0], pt[1]-0.5*h) text = 0 #axis values not drawn on right side def _ticks(self, lower, upper): ideal = (upper-lower)/7. log = Numeric.log10(ideal) power = Numeric.floor(log) fraction = log-power factor = 1. error = fraction for f, lf in self._multiples: e = Numeric.fabs(fraction-lf) if e < error: error = e factor = f grid = factor * 10.**power if power > 4 or power < -4: format = '%+7.1e' elif power >= 0: digits = max(1, int(power)) format = '%' + `digits`+'.0f' else: digits = -int(power) format = '%'+`digits+2`+'.'+`digits`+'f' ticks = [] t = -grid*Numeric.floor(-lower/grid) while t <= upper: ticks.append( (t, format % (t,)) ) t = t + grid return ticks _multiples = [(2., Numeric.log10(2.)), (5., Numeric.log10(5.))] #Used to layout the printer page class plot_printout(wx.Printout): """Controls how the plot is made in printing and previewing""" # Do not change method names in this class, # we have to override wxPrintout methods here! def __init__(self, graph): """graph is instance of plotCanvas to be printed or previewed""" wx.Printout.__init__(self) self.graph = graph def HasPage(self, page): if page == 1: return True else: return False def GetPageInfo(self): return (0, 1, 1, 1) #disable page numbers def OnPrintPage(self, page): dc = FloatDCWrapper(self.GetDC()) # allows using floats for certain functions ## print "PPI Printer",self.GetPPIPrinter() ## print "PPI Screen", self.GetPPIScreen() ## print "DC GetSize", dc.GetSize() ## print "GetPageSizePixels", self.GetPageSizePixels() #Note PPIScreen does not give the correct number #Calulate everything for printer and then scale for preview PPIPrinter= self.GetPPIPrinter() #printer dots/inch (w,h) #PPIScreen= self.GetPPIScreen() #screen dots/inch (w,h) dcSize= dc.GetSizeTuple() #DC size pageSize= self.GetPageSizePixels() #page size in terms of pixcels clientDcSize= self.graph.GetClientSizeTuple() #find what the margins are (mm) margLeftSize,margTopSize= self.graph.pageSetupData.GetMarginTopLeft() margRightSize, margBottomSize= self.graph.pageSetupData.<API key>() #calculate offset and scale for dc pixLeft= margLeftSize*PPIPrinter[0]/25.4 #mm*(dots/in)/(mm/in) pixRight= margRightSize*PPIPrinter[0]/25.4 pixTop= margTopSize*PPIPrinter[1]/25.4 pixBottom= margBottomSize*PPIPrinter[1]/25.4 plotAreaW= pageSize[0]-(pixLeft+pixRight) plotAreaH= pageSize[1]-(pixTop+pixBottom) #ratio offset and scale to screen size if preview if self.IsPreview(): ratioW= float(dcSize[0])/pageSize[0] ratioH= float(dcSize[1])/pageSize[1] pixLeft *= ratioW pixTop *= ratioH plotAreaW *= ratioW plotAreaH *= ratioH #rescale plot to page or preview plot area self.graph._setSize(plotAreaW,plotAreaH) #Set offset and scale dc.SetDeviceOrigin(pixLeft,pixTop) #Thicken up pens and increase marker size for printing ratioW= float(plotAreaW)/clientDcSize[0] ratioH= float(plotAreaH)/clientDcSize[1] aveScale= (ratioW+ratioH)/2 self.graph._setPrinterScale(aveScale) #tickens up pens for printing self.graph._printDraw(dc) #rescale back to original self.graph._setSize() self.graph._setPrinterScale(1) return True # Hack to allow plotting real numbers for the methods listed. # All others passed directly to DC. # For Drawing it is used as # dc = FloatDCWrapper(wx.BufferedDC(wx.ClientDC(self), self._Buffer)) # For printing is is used as # dc = FloatDCWrapper(self.GetDC()) class FloatDCWrapper: def __init__(self, aDC): self.theDC = aDC def DrawLine(self, x1,y1,x2,y2): self.theDC.DrawLine(int(x1),int(y1),int(x2),int(y2)) def DrawText(self, txt, x, y): self.theDC.DrawText(txt, int(x), int(y)) def DrawRotatedText(self, txt, x, y, angle): self.theDC.DrawRotatedText(txt, int(x), int(y), angle) def SetClippingRegion(self, x, y, width, height): self.theDC.SetClippingRegion(int(x), int(y), int(width), int(height)) def SetDeviceOrigin(self, x, y): self.theDC.SetDeviceOrigin(int(x), int(y)) def __getattr__(self, name): return getattr(self.theDC, name) # if running standalone... # ...a sample implementation using the above def __test(): from wxPython.lib.dialogs import <API key> def _draw1Objects(): # 100 points sin function, plotted as green circles data1 = 2.*Numeric.pi*Numeric.arange(200)/200. data1.shape = (100, 2) data1[:,1] = Numeric.sin(data1[:,0]) markers1 = PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1) # 50 points cos function, plotted as red line data1 = 2.*Numeric.pi*Numeric.arange(100)/100. data1.shape = (50,2) data1[:,1] = Numeric.cos(data1[:,0]) lines = PolyLine(data1, legend= 'Red Line', colour='red') # A few more points... pi = Numeric.pi markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), (3.*pi/4., -1)], legend='Cross Legend', colour='blue', marker='cross') return PlotGraphics([markers1, lines, markers2],"Graph Title", "X Axis", "Y Axis") def _draw2Objects(): # 100 points sin function, plotted as green dots data1 = 2.*Numeric.pi*Numeric.arange(200)/200. data1.shape = (100, 2) data1[:,1] = Numeric.sin(data1[:,0]) line1 = PolyLine(data1, legend='Green Line', colour='green', width=6, style=wx.DOT) # 50 points cos function, plotted as red dot-dash data1 = 2.*Numeric.pi*Numeric.arange(100)/100. data1.shape = (50,2) data1[:,1] = Numeric.cos(data1[:,0]) line2 = PolyLine(data1, legend='Red Line', colour='red', width=3, style= wx.DOT_DASH) # A few more points... pi = Numeric.pi markers1 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.), (3.*pi/4., -1)], legend='Cross Hatch Square', colour='blue', width= 3, size= 6, fillcolour= 'red', fillstyle= wx.CROSSDIAG_HATCH, marker='square') return PlotGraphics([markers1, line1, line2], "Big Markers with Different Line Styles") def _draw3Objects(): markerList= ['circle', 'dot', 'square', 'triangle', 'triangle_down', 'cross', 'plus', 'circle'] m=[] for i in range(len(markerList)): m.append(PolyMarker([(2*i+.5,i+.5)], legend=markerList[i], colour='blue', marker=markerList[i])) return PlotGraphics(m, "Selection of Markers", "Minimal Axis", "No Axis") def _draw4Objects(): # 25,000 point line data1 = Numeric.arange(5e5,1e6,10) data1.shape = (25000, 2) line1 = PolyLine(data1, legend='Wide Line', colour='green', width=5) # A few more points... markers2 = PolyMarker(data1, legend='Square', colour='blue', marker='square') return PlotGraphics([line1, markers2], "25,000 Points", "Value X", "") def _draw5Objects(): # Empty graph with axis defined but no points/lines points=[] line1 = PolyLine(points, legend='Wide Line', colour='green', width=5) return PlotGraphics([line1], "Empty Plot With Just Axes", "Value X", "Value Y") class AppFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(600, 400)) # Now Create the menu bar and items self.mainmenu = wx.MenuBar() menu = wx.Menu() menu.Append(200, 'Page Setup...', 'Setup the printer page') wx.EVT_MENU(self, 200, self.OnFilePageSetup) menu.Append(201, 'Print Preview...', 'Show the current plot on page') wx.EVT_MENU(self, 201, self.OnFilePrintPreview) menu.Append(202, 'Print...', 'Print the current plot') wx.EVT_MENU(self, 202, self.OnFilePrint) menu.Append(203, 'Save Plot...', 'Save current plot') wx.EVT_MENU(self, 203, self.OnSaveFile) menu.Append(205, 'E&xit', 'Enough of this already!') wx.EVT_MENU(self, 205, self.OnFileExit) self.mainmenu.Append(menu, '&File') menu = wx.Menu() menu.Append(206, 'Draw1', 'Draw plots1') wx.EVT_MENU(self,206,self.OnPlotDraw1) menu.Append(207, 'Draw2', 'Draw plots2') wx.EVT_MENU(self,207,self.OnPlotDraw2) menu.Append(208, 'Draw3', 'Draw plots3') wx.EVT_MENU(self,208,self.OnPlotDraw3) menu.Append(209, 'Draw4', 'Draw plots4') wx.EVT_MENU(self,209,self.OnPlotDraw4) menu.Append(210, 'Draw5', 'Draw plots5') wx.EVT_MENU(self,210,self.OnPlotDraw5) menu.Append(211, '&Redraw', 'Redraw plots') wx.EVT_MENU(self,211,self.OnPlotRedraw) menu.Append(212, '&Clear', 'Clear canvas') wx.EVT_MENU(self,212,self.OnPlotClear) menu.Append(213, '&Scale', 'Scale canvas') wx.EVT_MENU(self,213,self.OnPlotScale) menu.Append(214, 'Enable &Zoom', 'Enable Mouse Zoom', kind=wx.ITEM_CHECK) wx.EVT_MENU(self,214,self.OnEnableZoom) menu.Append(215, 'Enable &Grid', 'Turn on Grid', kind=wx.ITEM_CHECK) wx.EVT_MENU(self,215,self.OnEnableGrid) menu.Append(220, 'Enable &Legend', 'Turn on Legend', kind=wx.ITEM_CHECK) wx.EVT_MENU(self,220,self.OnEnableLegend) menu.Append(225, 'Scroll Up 1', 'Move View Up 1 Unit') wx.EVT_MENU(self,225,self.OnScrUp) menu.Append(230, 'Scroll Rt 2', 'Move View Right 2 Units') wx.EVT_MENU(self,230,self.OnScrRt) menu.Append(235, '&Plot Reset', 'Reset to original plot') wx.EVT_MENU(self,235,self.OnReset) self.mainmenu.Append(menu, '&Plot') menu = wx.Menu() menu.Append(300, '&About', 'About this thing...') wx.EVT_MENU(self, 300, self.OnHelpAbout) self.mainmenu.Append(menu, '&Help') self.SetMenuBar(self.mainmenu) # A status bar to tell people what's happening self.CreateStatusBar(1) self.client = PlotCanvas(self) #Create mouse event for showing cursor coords in status bar wx.EVT_LEFT_DOWN(self.client, self.OnMouseLeftDown) def OnMouseLeftDown(self,event): s= "Left Mouse Down at Point: (%.4f, %.4f)" % self.client.GetXY(event) self.SetStatusText(s) event.Skip() def OnFilePageSetup(self, event): self.client.PageSetup() def OnFilePrintPreview(self, event): self.client.PrintPreview() def OnFilePrint(self, event): self.client.Printout() def OnSaveFile(self, event): self.client.SaveFile() def OnFileExit(self, event): self.Close() def OnPlotDraw1(self, event): self.resetDefaults() self.client.Draw(_draw1Objects()) def OnPlotDraw2(self, event): self.resetDefaults() self.client.Draw(_draw2Objects()) def OnPlotDraw3(self, event): self.resetDefaults() self.client.SetFont(wx.Font(10,wx.SCRIPT,wx.NORMAL,wx.NORMAL)) self.client.SetFontSizeAxis(20) self.client.SetFontSizeLegend(12) self.client.SetXSpec('min') self.client.SetYSpec('none') self.client.Draw(_draw3Objects()) def OnPlotDraw4(self, event): self.resetDefaults() drawObj= _draw4Objects() self.client.Draw(drawObj) ## #profile ## start = time.clock() ## for x in range(10): ## self.client.Draw(drawObj) ## print "10 plots of Draw4 took: %f sec."%(time.clock() - start) ## #profile end def OnPlotDraw5(self, event): #Empty plot with just axes self.resetDefaults() drawObj= _draw5Objects() #make the axis X= (0,5), Y=(0,10) #(default with None is X= (-1,1), Y= (-1,1)) self.client.Draw(drawObj, xAxis= (0,5), yAxis= (0,10)) def OnPlotRedraw(self,event): self.client.Redraw() def OnPlotClear(self,event): self.client.Clear() def OnPlotScale(self, event): if self.client.last_draw != None: graphics, xAxis, yAxis= self.client.last_draw self.client.Draw(graphics,(1,3.05),(0,1)) def OnEnableZoom(self, event): self.client.SetEnableZoom(event.IsChecked()) def OnEnableGrid(self, event): self.client.SetEnableGrid(event.IsChecked()) def OnEnableLegend(self, event): self.client.SetEnableLegend(event.IsChecked()) def OnScrUp(self, event): self.client.ScrollUp(1) def OnScrRt(self,event): self.client.ScrollRight(2) def OnReset(self,event): self.client.Reset() def OnHelpAbout(self, event): about = <API key>(self, __doc__, "About...") about.ShowModal() def resetDefaults(self): """Just to reset the fonts back to the PlotCanvas defaults""" self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL)) self.client.SetFontSizeAxis(10) self.client.SetFontSizeLegend(7) self.client.SetXSpec('auto') self.client.SetYSpec('auto') class MyApp(wx.App): def OnInit(self): frame = AppFrame(None, -1, "wxPlotCanvas") frame.Show(True) self.SetTopWindow(frame) return True app = MyApp(0) app.MainLoop() if __name__ == '__main__': __test()
#ifndef NAMESPACE_TYPES_H #define NAMESPACE_TYPES_H #include <libetpan/clist.h> enum { <API key> }; struct <API key> { char * ns_name; /* != NULL */ clist * ns_values; /* != NULL, list of char * */ }; LIBETPAN_EXPORT struct <API key> * <API key>(char * name, clist * values); LIBETPAN_EXPORT void <API key>(struct <API key> * ext); struct <API key> { char * ns_prefix; /* != NULL */ char ns_delimiter; clist * ns_extensions; /* can be NULL, list of <API key> */ }; LIBETPAN_EXPORT struct <API key> * <API key>(char * prefix, char delimiter, clist * extensions); LIBETPAN_EXPORT void <API key>(struct <API key> * info); struct <API key> { clist * ns_data_list; /* != NULL, list of <API key> */ }; LIBETPAN_EXPORT struct <API key> * <API key>(clist * data_list); LIBETPAN_EXPORT void <API key>(struct <API key> * item); struct <API key> { struct <API key> * ns_personal; /* can be NULL */ struct <API key> * ns_other; /* can be NULL */ struct <API key> * ns_shared; /* can be NULL */ }; LIBETPAN_EXPORT struct <API key> * <API key>(struct <API key> * personal, struct <API key> * other, struct <API key> * shared); LIBETPAN_EXPORT void <API key>(struct <API key> * ns); #endif
// The LLVM Compiler Infrastructure // UNSUPPORTED: <API key> // <exception> // template<class E> exception_ptr make_exception_ptr(E e); #include <exception> #include <cassert> struct A { static int constructed; int data_; A(int data = 0) : data_(data) {++constructed;} ~A() {--constructed;} A(const A& a) : data_(a.data_) {++constructed;} }; int A::constructed = 0; int main() { { std::exception_ptr p = std::make_exception_ptr(A(5)); try { std::rethrow_exception(p); assert(false); } catch (const A& a) { #ifndef <API key> assert(A::constructed == 1); #else // On Windows exception_ptr copies the exception assert(A::constructed == 2); #endif assert(p != nullptr); p = nullptr; assert(p == nullptr); assert(a.data_ == 5); assert(A::constructed == 1); } assert(A::constructed == 0); } assert(A::constructed == 0); }
#include "third_party/blink/renderer/modules/shapedetection/shape_detector.h" #include <utility> #include "base/numerics/checked_math.h" #include "skia/ext/skia_utils_base.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_union_blob_htmlcanvaselement_htmlimageelement_htmlvideoelement_imagebitmap_imagedata_offscreencanvas_svgimageelement_videoframe.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/geometry/dom_rect.h" #include "third_party/blink/renderer/core/html/canvas/image_data.h" #include "third_party/blink/renderer/core/html/html_image_element.h" #include "third_party/blink/renderer/core/html/media/html_video_element.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h" #include "third_party/blink/renderer/core/loader/resource/<API key>.h" #include "third_party/blink/renderer/platform/graphics/image.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkImageInfo.h" namespace blink { ScriptPromise ShapeDetector::detect(ScriptState* script_state, const V8ImageBitmapSource* image_source) { DCHECK(image_source); auto* resolver = <API key><<API key>>(script_state); ScriptPromise promise = resolver->Promise(); CanvasImageSource* canvas_image_source = nullptr; switch (image_source->GetContentType()) { case V8ImageBitmapSource::ContentType::kHTMLCanvasElement: canvas_image_source = image_source-><API key>(); break; case V8ImageBitmapSource::ContentType::kHTMLImageElement: canvas_image_source = image_source-><API key>(); break; case V8ImageBitmapSource::ContentType::kHTMLVideoElement: canvas_image_source = image_source-><API key>(); break; case V8ImageBitmapSource::ContentType::kImageBitmap: canvas_image_source = image_source->GetAsImageBitmap(); break; case V8ImageBitmapSource::ContentType::kImageData: // ImageData cannot be tainted by definition. return <API key>(resolver, image_source->GetAsImageData()); case V8ImageBitmapSource::ContentType::kOffscreenCanvas: canvas_image_source = image_source-><API key>(); break; case V8ImageBitmapSource::ContentType::kBlob: case V8ImageBitmapSource::ContentType::kSVGImageElement: case V8ImageBitmapSource::ContentType::kVideoFrame: resolver->Reject(<API key><DOMException>( DOMExceptionCode::kNotSupportedError, "Unsupported source.")); return promise; } DCHECK(canvas_image_source); if (canvas_image_source->IsNeutered()) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "The image source is detached.")); return promise; } if (canvas_image_source->WouldTaintOrigin()) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kSecurityError, "Source would taint origin.")); return promise; } if (image_source->IsHTMLImageElement()) { return <API key>(resolver, image_source-><API key>()); } // TODO(mcasas): Check if |video| is actually playing a MediaStream by using // HTMLMediaElement::isMediaStreamURL(video->currentSrc().getString()); if // there is a local WebCam associated, there might be sophisticated ways to // detect faces on it. Until then, treat as a normal <video> element. const gfx::SizeF size = canvas_image_source->ElementSize(gfx::SizeF(), <API key>); SourceImageStatus source_image_status = <API key>; scoped_refptr<Image> image = canvas_image_source-><API key>(&source_image_status, size); if (!image || source_image_status != <API key>) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Invalid element or state.")); return promise; } if (size.IsEmpty()) { resolver->Resolve(HeapVector<Member<DOMRect>>()); return promise; } // GetSwSkImage() will make a raster copy of <API key>() // if needed, otherwise returning the original SkImage. const sk_sp<SkImage> sk_image = image-><API key>().GetSwSkImage(); SkBitmap sk_bitmap; SkBitmap n32_bitmap; if (!sk_image->asLegacyBitmap(&sk_bitmap) || !skia::<API key>(sk_bitmap, &n32_bitmap)) { // TODO(mcasas): retrieve the pixels from elsewhere. NOTREACHED(); resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to get pixels for current frame.")); return promise; } return DoDetect(resolver, std::move(n32_bitmap)); } ScriptPromise ShapeDetector::<API key>( <API key>* resolver, ImageData* image_data) { ScriptPromise promise = resolver->Promise(); if (image_data->Size().IsZero()) { resolver->Resolve(HeapVector<Member<DOMRect>>()); return promise; } if (image_data-><API key>()) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "The image data has been detached.")); return promise; } SkPixmap image_data_pixmap = image_data->GetSkPixmap(); SkBitmap sk_bitmap; if (!sk_bitmap.tryAllocPixels( image_data_pixmap.info().makeColorType(kN32_SkColorType), image_data_pixmap.rowBytes())) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to allocate pixels for current frame.")); return promise; } if (!sk_bitmap.writePixels(image_data_pixmap, 0, 0)) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to copy pixels for current frame.")); return promise; } return DoDetect(resolver, std::move(sk_bitmap)); } ScriptPromise ShapeDetector::<API key>( <API key>* resolver, const HTMLImageElement* img) { ScriptPromise promise = resolver->Promise(); <API key>* const image_content = img->CachedImage(); if (!image_content || !image_content->IsLoaded() || image_content->ErrorOccurred()) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to load or decode HTMLImageElement.")); return promise; } if (!image_content->HasImage()) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to get image from resource.")); return promise; } Image* const blink_image = image_content->GetImage(); if (blink_image->Size().IsZero()) { resolver->Resolve(HeapVector<Member<DOMRect>>()); return promise; } // The call to asLegacyBitmap() below forces a readback so getting SwSkImage // here doesn't readback unnecessarily const sk_sp<SkImage> sk_image = blink_image-><API key>().GetSwSkImage(); DCHECK_EQ(img->naturalWidth(), static_cast<unsigned>(sk_image->width())); DCHECK_EQ(img->naturalHeight(), static_cast<unsigned>(sk_image->height())); SkBitmap sk_bitmap; if (!sk_image || !sk_image->asLegacyBitmap(&sk_bitmap)) { resolver->Reject(<API key><DOMException>( DOMExceptionCode::kInvalidStateError, "Failed to get image from current frame.")); return promise; } return DoDetect(resolver, std::move(sk_bitmap)); } } // namespace blink
#pragma once #include <cstdint> #include <stdio.h> int crt_pipe(int *pfds, unsigned int psize, int textmode); int crt_close(int fd); int crt_read(int fd, void *buffer, unsigned int count); int crt_write(int fd, const void *buffer, unsigned int count); int crt_open(const char *filename, int oflag, int pmode); int crt_open_osfhandle(intptr_t osfhandle, int flags); intptr_t crtget_osfhandle(int fd); int crt_setmode(int fd, int mode); size_t crt_fwrite(const void * _Str, size_t _Size, size_t _Count, FILE * _File); int crt_fclose(FILE* file); int crt_fileno(FILE* file); int crt_isatty(int fd); int crt_access(const char *pathname, int mode); __int64 crt_lseek64(int fd, __int64 offset, int origin);
// <API key>: Apache-2.0 WITH LLVM-exception // <functional> // <API key> // UNSUPPORTED: c++98, c++03, c++11, c++14 #define <API key> #include <functional> #include <type_traits> #include <cassert> #include "test_macros.h" double unary_f(int i) {return 0.5 - i;} int main(int, char**) { typedef std::<API key><int, double> F; return 0; }
package net.sourceforge.pebble.web.view; import java.io.<API key>; import java.io.<API key>; import java.io.IOException; import java.io.File; import java.io.FilenameFilter; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.<API key>; import javax.xml.parsers.<API key>; import net.sourceforge.pebble.PebbleContext; import net.sourceforge.pebble.domain.Tag; import net.sourceforge.pebble.domain.BlogEntry; import net.sourceforge.pebble.util.StringUtils; import net.sourceforge.pebble.web.listener.<API key>; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Iterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.DocumentException; import org.xhtmlrenderer.pdf.ITextRenderer; import org.xhtmlrenderer.pdf.TrueTypeUtil; /** * Represents a binary view component and prepares the model for display. * * @author Alexander Zagniotov */ public class PdfView extends BinaryView { private static Log log = LogFactory.getLog(PdfView.class); private static final String SEP = "/"; private static final String FONTS_PATH = "fonts"; private static final String THEMES_PATH = "themes"; private static final String DEFAULT_ENCODING = "UTF-8"; private static final String PDF_CSS = "pdf.css"; private static final String SYSTEM_THEME_PATH = HtmlView.SYSTEM_THEME; private String filename = "default.pdf"; private BlogEntry entry; private long length = 0; public PdfView(BlogEntry entry, String filename) { this.entry = entry; this.filename = filename; } /** * Gets the title of this view. * * @return the title as a String */ public String getContentType() { return "application/pdf"; } public long getContentLength() { return length; } /** * Dispatches this view. * * @param request the HttpServletRequest instance * @param response the HttpServletResponse instance * @param context */ public void dispatch(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException { try { ITextRenderer renderer = new ITextRenderer(); //This will be an attachment response.setHeader("Content-Disposition", "attachment; filename=" + filename); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); String author = entry.getUser().getName(); String title = entry.getTitle(); String subtitle = entry.getSubtitle(); String body = entry.getBody(); String blogName = entry.getBlog().getName(); String entryPermalink = entry.getPermalink(); String entryDescription = entry.getBlog().getDescription(); //Some of the HTML entities need to be escaped to Unicode notation \\uXXXX for XHTML markup to validate title = StringUtils.transformHTML(title); subtitle = StringUtils.transformHTML(subtitle); body = StringUtils.<API key>(body); //Build absolute path to: <pebble_root>/themes/_pebble/fonts/ String webApplicationRoot = PebbleContext.getInstance().<API key>() + SEP + THEMES_PATH; //<pebble_root> + / + themes + / + _pebble + / + fonts String fontDirAbsolutePath = webApplicationRoot + SEP + SYSTEM_THEME_PATH + SEP + FONTS_PATH; File fontDir = new File(fontDirAbsolutePath); //Get blog entry tags for PDF metadata 'keywords' StringBuffer tags = new StringBuffer(); Iterator<Tag> currentEntryTags = entry.getAllTags().iterator(); //Build a string out of blog entry tags and seperate them by comma while (currentEntryTags.hasNext()) { Tag currentTag = currentEntryTags.next(); if (currentTag.getName() != null && !currentTag.getName().equals("")) { tags.append(currentTag.getName()); if (currentEntryTags.hasNext()) { tags.append(","); } } } //Build valid XHTML source from blog entry for parsing StringBuffer buf = new StringBuffer(); buf.append("<html>"); buf.append("<head>"); buf.append("<meta name=\"title\" content=\"" + title + " - " + blogName + "\"/>"); buf.append("<meta name=\"subject\" content=\"" + title + "\"/>"); buf.append("<meta name=\"keywords\" content=\"" + tags.toString().trim() + "\"/>"); buf.append("<meta name=\"author\" content=\"" + author + "\"/>"); buf.append("<meta name=\"creator\" content=\"Pebble (by pebble.sourceforge.net)\"/>"); buf.append("<meta name=\"producer\" content=\"Flying Saucer (by xhtmlrenderer.dev.java.net)\"/>"); buf.append("<link rel='stylesheet' type='text/css' href='" + entry.getBlog().getUrl() + THEMES_PATH + SEP + SYSTEM_THEME_PATH + SEP + PDF_CSS + "' media='print' />"); buf.append("</head>"); buf.append("<body>"); buf.append("<div id=\"header\" style=\"\">" + blogName + " - " + entryDescription + "</div>"); buf.append("<p>"); //Gets TTF or OTF font file from the font directory in the system theme folder if (fontDir.isDirectory()) { File[] files = fontDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { String lower = name.toLowerCase(); //Load TTF or OTF files return lower.endsWith(".otf") || lower.endsWith(".ttf"); } }); if (files.length > 0) { String fontFamilyName = ""; //You should always embed TrueType fonts. renderer.getFontResolver().addFont(files[0].getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); log.info("Added font: " + files[0].getAbsolutePath()); //Get font family name from the BaseFont object. All this work just to get font family name BaseFont font = BaseFont.createFont(files[0].getAbsolutePath(), BaseFont.IDENTITY_H , BaseFont.NOT_EMBEDDED); fontFamilyName = TrueTypeUtil.getFamilyName(font); if (!fontFamilyName.equals("")) { //Wrap DIV with font family name around the content of the blog entry author = "<div style=\"font-family: " + fontFamilyName + ";\">" + author + "</div>"; title = "<div style=\"font-family: " + fontFamilyName + ";\">" + title + "</div>"; subtitle = "<div style=\"font-family: " + fontFamilyName + ";\">" + subtitle + "</div>"; body = "<div style=\"font-family: " + fontFamilyName + ";\">" + body + "</div>"; log.info("PDFGenerator - Added font family: '" + fontFamilyName + "' to PDF content"); } } } buf.append("<h1>" + title + "</h1>"); buf.append("<h2>" + subtitle + "</h2>"); buf.append("</p>"); buf.append("<p>" + body + "</p>"); buf.append("<p><br /><br /><br />"); buf.append("<i>Published by " + author + "</i><br />"); buf.append("<i>" + entry.getDate().toString() + "</i><br />"); buf.append("<i><a href=\"" + entryPermalink + "\" title=\"" + entryPermalink + "\">" + entryPermalink + "</a></i>"); buf.append("</p>"); buf.append("</body>"); buf.append("</html>"); byte[] bytes = buf.toString().getBytes(DEFAULT_ENCODING); <API key> bais = new <API key>(bytes); DocumentBuilder builder = <API key>.newInstance().newDocumentBuilder(); InputSource is = new InputSource(bais); Document doc = builder.parse(is); //Listener that will parse HTML header meta tags, and will set them to PDF document as meta data <API key> pdfListener = new <API key>(); pdfListener.parseMetaTags(doc); renderer.setListener(pdfListener); renderer.setDocument(doc, null); renderer.layout(); <API key> bufferedOutput = new <API key>(response.getOutputStream()); renderer.createPDF(bufferedOutput); bufferedOutput.flush(); bufferedOutput.close(); log.info("Successfully generated PDF document: " + filename); } catch (<API key> e) { log.error("Could not create PDF, could not get new instance of DocumentBuilder: " + e); } catch (SAXException e) { log.error("Could not create PDF, could not parse InputSource: " + e); } catch (IOException e) { log.error("Could not create PDF: " + e); } catch (DocumentException e) { log.error("iText could not create PDF document: " + e); } catch (Exception e) { log.error("Could not create PDF: " + e); } } }
#include "ui/views/test/<API key>.h" #include "base/path_service.h" #include "mojo/shell/public/cpp/application_impl.h" #include "mojo/shell/public/cpp/<API key>.h" #include "ui/aura/env.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" #include "ui/gl/test/<API key>.h" #include "ui/views/mus/<API key>.h" namespace views { namespace { class <API key> : public PlatformTestHelper { public: <API key>() { gfx::<API key>::InitializeOneOff(); // TODO(sky): We really shouldn't need to configure ResourceBundle. ui::<API key>(); base::FilePath ui_test_pak_path; CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); ui::ResourceBundle::<API key>(ui_test_pak_path); aura::Env::CreateInstance(true); mojo_test_helper_.reset(new mojo::test::TestHelper(nullptr)); // ui/views/mus requires a WindowManager running, for now use the desktop // one. mojo_test_helper_->application_impl()-><API key>( "mojo:desktop_wm"); <API key>::Create(mojo_test_helper_->application_impl()); } ~<API key>() override { mojo_test_helper_.reset(nullptr); aura::Env::DeleteInstance(); ui::ResourceBundle::<API key>(); } private: scoped_ptr<mojo::test::TestHelper> mojo_test_helper_; <API key>(<API key>); }; } // namespace // static scoped_ptr<PlatformTestHelper> PlatformTestHelper::Create() { return make_scoped_ptr(new <API key>); } } // namespace views
<?php namespace ZendTest\Filter; use Zend\Filter\Digits as DigitsFilter; /** * @group Zend_Filter */ class DigitsTest extends \<API key> { /** * Is PCRE is compiled with UTF-8 and Unicode support * * @var mixed **/ protected static $_unicodeEnabled; /** * Creates a new Zend_Filter_Digits object for each test method * * @return void */ public function setUp() { if (null === static::$_unicodeEnabled) { static::$_unicodeEnabled = (bool) @preg_match('/\pL/u', 'a'); } } /** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $filter = new DigitsFilter(); if (static::$_unicodeEnabled && extension_loaded('mbstring')) { // Filter for the value with mbstring /** * The first element of $valuesExpected contains multibyte digit characters. * But , Zend_Filter_Digits is expected to return only singlebyte digits. * * The second contains multibyte or singebyte space, and also alphabet. * The third contains various multibyte characters. * The last contains only singlebyte digits. */ $valuesExpected = array( '123' => '123', ' 4.5B6' => '456', '987654' => '987654', '789' => '789' ); } else { // POSIX named classes are not supported, use alternative 0-9 match // Or filter for the value without mbstring $valuesExpected = array( 'abc123' => '123', 'abc 123' => '123', 'abcxyz' => '', 'AZ@#4.3' => '43', '1.23' => '123', '0x9f' => '09' ); } foreach ($valuesExpected as $input => $output) { $this->assertEquals( $output, $result = $filter($input), "Expected '$input' to filter to '$output', but received '$result' instead" ); } } public function <API key>() { return array( array(null), array(new \stdClass()), array(array( 'abc123', 'abc 123' )), array(true), array(false), ); } /** * @dataProvider <API key> * @return void */ public function <API key>($input) { $filter = new DigitsFilter(); $this->assertSame($input, $filter($input)); } }
#include "cc/playback/<API key>.h" #include "cc/playback/clip_display_item.h" #include "cc/playback/<API key>.h" #include "cc/playback/<API key>.h" #include "cc/playback/<API key>.h" #include "cc/playback/filter_display_item.h" #include "cc/playback/<API key>.h" #include "cc/playback/<API key>.h" #include "cc/proto/display_item.pb.h" #include "ui/gfx/geometry/rect.h" namespace cc { // static void <API key>::<API key>( const gfx::Rect& visual_rect, DisplayItemList* list, const proto::DisplayItem& proto) { switch (proto.type()) { case proto::DisplayItem::Type_Clip: list->CreateAndAppendItem<ClipDisplayItem>(visual_rect, proto); return; case proto::DisplayItem::Type_EndClip: list->CreateAndAppendItem<EndClipDisplayItem>(visual_rect, proto); return; case proto::DisplayItem::Type_ClipPath: list->CreateAndAppendItem<ClipPathDisplayItem>(visual_rect, proto); return; case proto::DisplayItem::Type_EndClipPath: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_Compositing: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_EndCompositing: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_Drawing: list->CreateAndAppendItem<DrawingDisplayItem>(visual_rect, proto); return; case proto::DisplayItem::Type_Filter: list->CreateAndAppendItem<FilterDisplayItem>(visual_rect, proto); return; case proto::DisplayItem::Type_EndFilter: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_FloatClip: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_EndFloatClip: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_Transform: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; case proto::DisplayItem::Type_EndTransform: list->CreateAndAppendItem<<API key>>(visual_rect, proto); return; } NOTREACHED(); } } // namespace cc
#include "chrome/browser/extensions/api/declarative_content/content_action.h" #include <map> #include "base/lazy_instance.h" #include "base/strings/stringprintf.h" #include "base/values.h" #include "chrome/browser/extensions/api/declarative_content/content_constants.h" #include "chrome/browser/extensions/api/extension_action/<API key>.h" #include "chrome/browser/extensions/extension_action.h" #include "chrome/browser/extensions/<API key>.h" #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sessions/session_tab_helper.h" #include "content/public/browser/invalidate_type.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/<API key>.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" #include "extensions/common/extension.h" #include "extensions/common/extension_messages.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" namespace extensions { namespace keys = <API key>; namespace { // Error messages. const char <API key>[] = "Icon dictionary must be of the form {\"19\": ImageData1, \"38\": " "ImageData2}"; const char <API key>[] = "An action has an invalid instanceType: %s"; const char kMissingParameter[] = "Missing parameter is required: %s"; const char kNoPageAction[] = "Can't use declarativeContent.ShowPageAction without a page action"; const char <API key>[] = "Can't use declarativeContent.SetIcon without a page or browser action"; #define <API key>(test) do { \ if (!(test)) { \ *bad_message = true; \ return false; \ } \ } while (0) // The following are concrete actions. // Action that instructs to show an extension's page action. class ShowPageAction : public ContentAction { public: ShowPageAction() {} static scoped_refptr<ContentAction> Create( content::BrowserContext* browser_context, const Extension* extension, const base::DictionaryValue* dict, std::string* error, bool* bad_message) { // We can't show a page action if the extension doesn't have one. if (ActionInfo::GetPageActionInfo(extension) == NULL) { *error = kNoPageAction; return scoped_refptr<ContentAction>(); } return scoped_refptr<ContentAction>(new ShowPageAction); } // Implementation of ContentAction: Type GetType() const override { return <API key>; } void Apply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override { ExtensionAction* action = GetPageAction(apply_info->browser_context, extension_id); action->DeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); ExtensionActionAPI::Get(apply_info->browser_context)->NotifyChange( action, apply_info->tab, apply_info->browser_context); } // The page action is already showing, so nothing needs to be done here. void Reapply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override {} void Revert(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override { if (ExtensionAction* action = GetPageAction(apply_info->browser_context, extension_id)) { action->UndoDeclarativeShow(ExtensionTabUtil::GetTabId(apply_info->tab)); ExtensionActionAPI::Get(apply_info->browser_context)->NotifyChange( action, apply_info->tab, apply_info->browser_context); } } private: static ExtensionAction* GetPageAction( content::BrowserContext* browser_context, const std::string& extension_id) { const Extension* extension = ExtensionRegistry::Get(browser_context) ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); if (!extension) return NULL; return <API key>::Get(browser_context) ->GetPageAction(*extension); } ~ShowPageAction() override {} <API key>(ShowPageAction); }; // Action that sets an extension's action icon. class SetIcon : public ContentAction { public: SetIcon(const gfx::Image& icon, ActionInfo::Type action_type) : icon_(icon), action_type_(action_type) {} static scoped_refptr<ContentAction> Create( content::BrowserContext* browser_context, const Extension* extension, const base::DictionaryValue* dict, std::string* error, bool* bad_message); // Implementation of ContentAction: Type GetType() const override { return ACTION_SET_ICON; } void Apply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override { Profile* profile = Profile::FromBrowserContext(apply_info->browser_context); ExtensionAction* action = GetExtensionAction(profile, extension_id); if (action) { action->DeclarativeSetIcon(ExtensionTabUtil::GetTabId(apply_info->tab), apply_info->priority, icon_); ExtensionActionAPI::Get(profile) ->NotifyChange(action, apply_info->tab, profile); } } void Reapply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override {} void Revert(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const override { Profile* profile = Profile::FromBrowserContext(apply_info->browser_context); ExtensionAction* action = GetExtensionAction(profile, extension_id); if (action) { action-><API key>( ExtensionTabUtil::GetTabId(apply_info->tab), apply_info->priority, icon_); ExtensionActionAPI::Get(apply_info->browser_context) ->NotifyChange(action, apply_info->tab, profile); } } private: ExtensionAction* GetExtensionAction(Profile* profile, const std::string& extension_id) const { const Extension* extension = ExtensionRegistry::Get(profile) ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); if (!extension) return NULL; switch (action_type_) { case ActionInfo::TYPE_BROWSER: return <API key>::Get(profile) ->GetBrowserAction(*extension); case ActionInfo::TYPE_PAGE: return <API key>::Get(profile)->GetPageAction(*extension); default: NOTREACHED(); } return NULL; } ~SetIcon() override {} gfx::Image icon_; ActionInfo::Type action_type_; <API key>(SetIcon); }; // Helper for getting JS collections into C++. static bool <API key>(const base::ListValue& append_strings, std::vector<std::string>* append_to) { for (base::ListValue::const_iterator it = append_strings.begin(); it != append_strings.end(); ++it) { std::string value; if ((*it)->GetAsString(&value)) { append_to->push_back(value); } else { return false; } } return true; } struct <API key> { // Factory methods for ContentAction instances. |extension| is the extension // for which the action is being created. |dict| contains the json dictionary // that describes the action. |error| is used to return error messages in case // the extension passed an action that was syntactically correct but // semantically incorrect. |bad_message| is set to true in case |dict| does // not confirm to the validated JSON specification. typedef scoped_refptr<ContentAction>(*FactoryMethod)( content::BrowserContext* /* browser_context */, const Extension* /* extension */, const base::DictionaryValue* /* dict */, std::string* /* error */, bool* /* bad_message */); // Maps the name of a declarativeContent action type to the factory // function creating it. std::map<std::string, FactoryMethod> factory_methods; <API key>() { factory_methods[keys::kShowPageAction] = &ShowPageAction::Create; factory_methods[keys::<API key>] = &<API key>::Create; factory_methods[keys::kSetIcon] = &SetIcon::Create; } }; base::LazyInstance<<API key>>::Leaky <API key> = <API key>; } // namespace // <API key> struct <API key>::ScriptData { ScriptData(); ~ScriptData(); std::vector<std::string> css_file_names; std::vector<std::string> js_file_names; bool all_frames; bool match_about_blank; }; <API key>::ScriptData::ScriptData() : all_frames(false), match_about_blank(false) {} <API key>::ScriptData::~ScriptData() {} // static scoped_refptr<ContentAction> <API key>::Create( content::BrowserContext* browser_context, const Extension* extension, const base::DictionaryValue* dict, std::string* error, bool* bad_message) { ScriptData script_data; if (!InitScriptData(dict, error, bad_message, &script_data)) return scoped_refptr<ContentAction>(); return scoped_refptr<ContentAction>(new <API key>( browser_context, extension, script_data)); } // static scoped_refptr<ContentAction> <API key>::CreateForTest( <API key>* master, const Extension* extension, const base::Value& json_action, std::string* error, bool* bad_message) { // Simulate ContentAction-level initialization. Check that instance type is // <API key>. ContentAction::ResetErrorData(error, bad_message); const base::DictionaryValue* action_dict = NULL; std::string instance_type; if (!ContentAction::Validate( json_action, error, bad_message, &action_dict, &instance_type) || instance_type != std::string(keys::<API key>)) return scoped_refptr<ContentAction>(); // Normal <API key> data initialization. ScriptData script_data; if (!InitScriptData(action_dict, error, bad_message, &script_data)) return scoped_refptr<ContentAction>(); // Inject provided <API key>, rather than looking it up // using a BrowserContext. return scoped_refptr<ContentAction>(new <API key>( master, extension, script_data)); } // static bool <API key>::InitScriptData(const base::DictionaryValue* dict, std::string* error, bool* bad_message, ScriptData* script_data) { const base::ListValue* list_value = NULL; if (!dict->HasKey(keys::kCss) && !dict->HasKey(keys::kJs)) { *error = base::StringPrintf(kMissingParameter, "css or js"); return false; } if (dict->HasKey(keys::kCss)) { <API key>(dict->GetList(keys::kCss, &list_value)); <API key>( <API key>(*list_value, &script_data->css_file_names)); } if (dict->HasKey(keys::kJs)) { <API key>(dict->GetList(keys::kJs, &list_value)); <API key>( <API key>(*list_value, &script_data->js_file_names)); } if (dict->HasKey(keys::kAllFrames)) { <API key>( dict->GetBoolean(keys::kAllFrames, &script_data->all_frames)); } if (dict->HasKey(keys::kMatchAboutBlank)) { <API key>( dict->GetBoolean( keys::kMatchAboutBlank, &script_data->match_about_blank)); } return true; } <API key>::<API key>( content::BrowserContext* browser_context, const Extension* extension, const ScriptData& script_data) { HostID host_id(HostID::EXTENSIONS, extension->id()); InitScript(host_id, extension, script_data); master_ = ExtensionSystem::Get(browser_context) -><API key>() -><API key>(host_id); AddScript(); } <API key>::<API key>( <API key>* master, const Extension* extension, const ScriptData& script_data) { HostID host_id(HostID::EXTENSIONS, extension->id()); InitScript(host_id, extension, script_data); master_ = master; AddScript(); } <API key>::~<API key>() { DCHECK(master_); master_->RemoveScript(script_); } void <API key>::InitScript(const HostID& host_id, const Extension* extension, const ScriptData& script_data) { script_.set_id(UserScript::<API key>()); script_.set_host_id(host_id); script_.set_run_location(UserScript::BROWSER_DRIVEN); script_.<API key>(script_data.all_frames); script_.<API key>(script_data.match_about_blank); for (std::vector<std::string>::const_iterator it = script_data.css_file_names.begin(); it != script_data.css_file_names.end(); ++it) { GURL url = extension->GetResourceURL(*it); ExtensionResource resource = extension->GetResource(*it); script_.css_scripts().push_back(UserScript::File( resource.extension_root(), resource.relative_path(), url)); } for (std::vector<std::string>::const_iterator it = script_data.js_file_names.begin(); it != script_data.js_file_names.end(); ++it) { GURL url = extension->GetResourceURL(*it); ExtensionResource resource = extension->GetResource(*it); script_.js_scripts().push_back(UserScript::File( resource.extension_root(), resource.relative_path(), url)); } } ContentAction::Type <API key>::GetType() const { return <API key>; } void <API key>::Apply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const { <API key>(apply_info->tab, extension_id); } void <API key>::Reapply(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const { <API key>(apply_info->tab, extension_id); } void <API key>::Revert(const std::string& extension_id, const base::Time& <API key>, ApplyInfo* apply_info) const {} void <API key>::<API key>( content::WebContents* contents, const std::string& extension_id) const { content::RenderViewHost* render_view_host = contents->GetRenderViewHost(); render_view_host->Send(new <API key>( render_view_host->GetRoutingID(), SessionTabHelper::IdForTab(contents), extension_id, script_.id(), contents->GetLastCommittedURL())); } // static scoped_refptr<ContentAction> SetIcon::Create( content::BrowserContext* browser_context, const Extension* extension, const base::DictionaryValue* dict, std::string* error, bool* bad_message) { // We can't set a page or action's icon if the extension doesn't have one. ActionInfo::Type type; if (ActionInfo::GetPageActionInfo(extension) != NULL) { type = ActionInfo::TYPE_PAGE; } else if (ActionInfo::<API key>(extension) != NULL) { type = ActionInfo::TYPE_BROWSER; } else { *error = <API key>; return scoped_refptr<ContentAction>(); } gfx::ImageSkia icon; const base::DictionaryValue* canvas_set = NULL; if (dict->GetDictionary("imageData", &canvas_set) && !ExtensionAction::<API key>(*canvas_set, &icon)) { *error = <API key>; *bad_message = true; return scoped_refptr<ContentAction>(); } return scoped_refptr<ContentAction>(new SetIcon(gfx::Image(icon), type)); } // ContentAction ContentAction::ContentAction() {} ContentAction::~ContentAction() {} // static scoped_refptr<ContentAction> ContentAction::Create( content::BrowserContext* browser_context, const Extension* extension, const base::Value& json_action, std::string* error, bool* bad_message) { ResetErrorData(error, bad_message); const base::DictionaryValue* action_dict = NULL; std::string instance_type; if (!Validate(json_action, error, bad_message, &action_dict, &instance_type)) return scoped_refptr<ContentAction>(); <API key>& factory = <API key>.Get(); std::map<std::string, <API key>::FactoryMethod>::iterator factory_method_iter = factory.factory_methods.find(instance_type); if (factory_method_iter != factory.factory_methods.end()) return (*factory_method_iter->second)( browser_context, extension, action_dict, error, bad_message); *error = base::StringPrintf(<API key>, instance_type.c_str()); return scoped_refptr<ContentAction>(); } bool ContentAction::Validate(const base::Value& json_action, std::string* error, bool* bad_message, const base::DictionaryValue** action_dict, std::string* instance_type) { <API key>(json_action.GetAsDictionary(action_dict)); <API key>( (*action_dict)->GetString(keys::kInstanceType, instance_type)); return true; } } // namespace extensions
#ifndef <API key> #define <API key> #include <stdint.h> #include <memory> #include "ppapi/c/<API key>.h" #include "ppapi/shared_impl/ppapi_shared_export.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/ppb_graphics_3d_api.h" #include "ui/gfx/geometry/size.h" namespace gpu { class CommandBuffer; class GpuControl; class TransferBuffer; namespace gles2 { class GLES2CmdHelper; class GLES2Implementation; class GLES2Interface; } // namespace gles2 } // namespace gpu. namespace ppapi { class PPAPI_SHARED_EXPORT <API key> : public Resource, public thunk::PPB_Graphics3D_API { public: <API key>(const <API key>&) = delete; <API key>& operator=(const <API key>&) = delete; // Resource overrides. thunk::PPB_Graphics3D_API* <API key>() override; // PPB_Graphics3D_API implementation. int32_t GetAttribs(int32_t attrib_list[]) override; int32_t SetAttribs(const int32_t attrib_list[]) override; int32_t GetError() override; int32_t ResizeBuffers(int32_t width, int32_t height) override; int32_t SwapBuffers(scoped_refptr<TrackedCallback> callback) override; int32_t <API key>(scoped_refptr<TrackedCallback> callback, const gpu::SyncToken& sync_token, const gfx::Size& size) override; int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) override; void* <API key>(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum access) override; void <API key>(const void* mem) override; gpu::gles2::GLES2Implementation* gles2_impl() { return gles2_impl_.get(); } gpu::gles2::GLES2Interface* gles2_interface(); // Sends swap-buffers notification to the plugin. void SwapBuffersACK(int32_t pp_error); protected: <API key>(PP_Instance instance); <API key>(const HostResource& host_resource, const gfx::Size& size); ~<API key>() override; virtual gpu::CommandBuffer* GetCommandBuffer() = 0; virtual gpu::GpuControl* GetGpuControl() = 0; virtual int32_t DoSwapBuffers(const gpu::SyncToken& sync_token, const gfx::Size& size) = 0; bool HasPendingSwap() const; bool CreateGLES2Impl(gpu::gles2::GLES2Implementation* share_gles2); void DestroyGLES2Impl(); private: std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; std::unique_ptr<gpu::gles2::GLES2Implementation> gles2_impl_; // A local cache of the size of the viewport. This is only valid in plugin // resources. gfx::Size size_; // Callback that needs to be executed when swap-buffers is completed. scoped_refptr<TrackedCallback> swap_callback_; }; } // namespace ppapi #endif // <API key>
#include "libxml.h" #ifdef LIBXML_HTML_ENABLED #include <string.h> #include <stdarg.h> #include <stdlib.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> #endif #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #include <libxml/xmlmemory.h> #include <libxml/HTMLparser.h> #include <libxml/HTMLtree.h> #include <libxml/debugXML.h> #include <libxml/xmlerror.h> #include <libxml/globals.h> #ifdef <API key> static int debug = 0; #endif static int copy = 0; static int sax = 0; static int repeat = 0; static int noout = 0; #ifdef LIBXML_PUSH_ENABLED static int push = 0; #endif /* LIBXML_PUSH_ENABLED */ static char *encoding = NULL; static int options = 0; static xmlSAXHandler <API key> = { NULL, /* internalSubset */ NULL, /* isStandalone */ NULL, /* hasInternalSubset */ NULL, /* hasExternalSubset */ NULL, /* resolveEntity */ NULL, /* getEntity */ NULL, /* entityDecl */ NULL, /* notationDecl */ NULL, /* attributeDecl */ NULL, /* elementDecl */ NULL, /* unparsedEntityDecl */ NULL, /* setDocumentLocator */ NULL, /* startDocument */ NULL, /* endDocument */ NULL, /* startElement */ NULL, /* endElement */ NULL, /* reference */ NULL, /* characters */ NULL, /* ignorableWhitespace */ NULL, /* <API key> */ NULL, /* comment */ NULL, /* xmlParserWarning */ NULL, /* xmlParserError */ NULL, /* xmlParserError */ NULL, /* getParameterEntity */ NULL, /* cdataBlock */ NULL, /* externalSubset */ 1, /* initialized */ NULL, /* private */ NULL, /* <API key> */ NULL, /* <API key> */ NULL /* <API key> */ }; static xmlSAXHandlerPtr emptySAXHandler = &<API key>; extern xmlSAXHandlerPtr debugSAXHandler; /** * isStandaloneDebug: * @ctxt: An XML parser context * * Is this document tagged standalone ? * * Returns 1 if true */ static int isStandaloneDebug(void *ctx ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.isStandalone()\n"); return(0); } /** * <API key>: * @ctxt: An XML parser context * * Does this document has an internal subset * * Returns 1 if true */ static int <API key>(void *ctx ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.hasInternalSubset()\n"); return(0); } /** * <API key>: * @ctxt: An XML parser context * * Does this document has an external subset * * Returns 1 if true */ static int <API key>(void *ctx ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.hasExternalSubset()\n"); return(0); } /** * <API key>: * @ctxt: An XML parser context * * Does this document has an internal subset */ static void internalSubsetDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { fprintf(stdout, "SAX.internalSubset(%s,", name); if (ExternalID == NULL) fprintf(stdout, " ,"); else fprintf(stdout, " %s,", ExternalID); if (SystemID == NULL) fprintf(stdout, " )\n"); else fprintf(stdout, " %s)\n", SystemID); } /** * resolveEntityDebug: * @ctxt: An XML parser context * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * Special entity resolver, better left to the parser, it has * more context than the application layer. * The default behaviour is to NOT resolve the entities, in that case * the ENTITY_REF nodes are built in the structure (and the parameter * values). * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ static xmlParserInputPtr resolveEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *publicId, const xmlChar *systemId) { /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ fprintf(stdout, "SAX.resolveEntity("); if (publicId != NULL) fprintf(stdout, "%s", (char *)publicId); else fprintf(stdout, " "); if (systemId != NULL) fprintf(stdout, ", %s)\n", (char *)systemId); else fprintf(stdout, ", )\n"); return(NULL); } /** * getEntityDebug: * @ctxt: An XML parser context * @name: The entity name * * Get an entity by name * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ static xmlEntityPtr getEntityDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { fprintf(stdout, "SAX.getEntity(%s)\n", name); return(NULL); } /** * <API key>: * @ctxt: An XML parser context * @name: The entity name * * Get a parameter entity by name * * Returns the xmlParserInputPtr */ static xmlEntityPtr <API key>(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); return(NULL); } /** * entityDeclDebug: * @ctxt: An XML parser context * @name: the entity name * @type: the entity type * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @content: the entity value (without processing). * * An entity definition has been parsed */ static void entityDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) { fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", name, type, publicId, systemId, content); } /** * attributeDeclDebug: * @ctxt: An XML parser context * @name: the attribute name * @type: the attribute type * * An attribute definition has been parsed */ static void attributeDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *elem, const xmlChar *name, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", elem, name, type, def, defaultValue); } /** * elementDeclDebug: * @ctxt: An XML parser context * @name: the element name * @type: the element type * @content: the element value (without processing). * * An element definition has been parsed */ static void elementDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, int type, <API key> content ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", name, type); } /** * notationDeclDebug: * @ctxt: An XML parser context * @name: The name of the notation * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * What to do when a notation declaration has been parsed. */ static void notationDeclDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) { fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", (char *) name, (char *) publicId, (char *) systemId); } /** * <API key>: * @ctxt: An XML parser context * @name: The name of the entity * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @notationName: the name of the notation * * What to do when an unparsed entity declaration is parsed */ static void <API key>(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName) { fprintf(stdout, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", (char *) name, (char *) publicId, (char *) systemId, (char *) notationName); } /** * <API key>: * @ctxt: An XML parser context * @loc: A SAX Locator * * Receive the document locator at startup, actually <API key> * Everything is available on the context, so this is useless in our case. */ static void <API key>(void *ctx ATTRIBUTE_UNUSED, xmlSAXLocatorPtr loc ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.setDocumentLocator()\n"); } /** * startDocumentDebug: * @ctxt: An XML parser context * * called when the document start being processed. */ static void startDocumentDebug(void *ctx ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.startDocument()\n"); } /** * endDocumentDebug: * @ctxt: An XML parser context * * called when the document end has been detected. */ static void endDocumentDebug(void *ctx ATTRIBUTE_UNUSED) { fprintf(stdout, "SAX.endDocument()\n"); } /** * startElementDebug: * @ctxt: An XML parser context * @name: The element name * * called when an opening tag has been processed. */ static void startElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name, const xmlChar **atts) { int i; fprintf(stdout, "SAX.startElement(%s", (char *) name); if (atts != NULL) { for (i = 0;(atts[i] != NULL);i++) { fprintf(stdout, ", %s", atts[i++]); if (atts[i] != NULL) { unsigned char output[40]; const unsigned char *att = atts[i]; int outlen, attlen; fprintf(stdout, "='"); while ((attlen = strlen((char*)att)) > 0) { outlen = sizeof output - 1; htmlEncodeEntities(output, &outlen, att, &attlen, '\''); output[outlen] = 0; fprintf(stdout, "%s", (char *) output); att += attlen; } fprintf(stdout, "'"); } } } fprintf(stdout, ")\n"); } /** * endElementDebug: * @ctxt: An XML parser context * @name: The element name * * called when the end of an element has been detected. */ static void endElementDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); } /** * charactersDebug: * @ctxt: An XML parser context * @ch: a xmlChar string * @len: the number of xmlChar * * receiving some chars from the parser. * Question: how much at a time ??? */ static void charactersDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) { unsigned char output[40]; int inlen = len, outlen = 30; htmlEncodeEntities(output, &outlen, ch, &inlen, 0); output[outlen] = 0; fprintf(stdout, "SAX.characters(%s, %d)\n", output, len); } /** * cdataDebug: * @ctxt: An XML parser context * @ch: a xmlChar string * @len: the number of xmlChar * * receiving some cdata chars from the parser. * Question: how much at a time ??? */ static void cdataDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) { unsigned char output[40]; int inlen = len, outlen = 30; htmlEncodeEntities(output, &outlen, ch, &inlen, 0); output[outlen] = 0; fprintf(stdout, "SAX.cdata(%s, %d)\n", output, len); } /** * referenceDebug: * @ctxt: An XML parser context * @name: The entity name * * called when an entity reference is detected. */ static void referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name) { fprintf(stdout, "SAX.reference(%s)\n", name); } /** * <API key>: * @ctxt: An XML parser context * @ch: a xmlChar string * @start: the first char in the string * @len: the number of xmlChar * * receiving some ignorable whitespaces from the parser. * Question: how much at a time ??? */ static void <API key>(void *ctx ATTRIBUTE_UNUSED, const xmlChar *ch, int len) { char output[40]; int i; for (i = 0;(i<len) && (i < 30);i++) output[i] = ch[i]; output[i] = 0; fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len); } /** * <API key>: * @ctxt: An XML parser context * @target: the target name * @data: the PI data's * @len: the number of xmlChar * * A processing instruction has been parsed. */ static void <API key>(void *ctx ATTRIBUTE_UNUSED, const xmlChar *target, const xmlChar *data) { fprintf(stdout, "SAX.<API key>(%s, %s)\n", (char *) target, (char *) data); } /** * commentDebug: * @ctxt: An XML parser context * @value: the comment content * * A comment has been parsed. */ static void commentDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *value) { fprintf(stdout, "SAX.comment(%s)\n", value); } /** * warningDebug: * @ctxt: An XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a warning messages, gives file, line, position and * extra parameters. */ static void XMLCDECL warningDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; va_start(args, msg); fprintf(stdout, "SAX.warning: "); vfprintf(stdout, msg, args); va_end(args); } /** * errorDebug: * @ctxt: An XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a error messages, gives file, line, position and * extra parameters. */ static void XMLCDECL errorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; va_start(args, msg); fprintf(stdout, "SAX.error: "); vfprintf(stdout, msg, args); va_end(args); } /** * fatalErrorDebug: * @ctxt: An XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a fatalError messages, gives file, line, position and * extra parameters. */ static void XMLCDECL fatalErrorDebug(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { va_list args; va_start(args, msg); fprintf(stdout, "SAX.fatalError: "); vfprintf(stdout, msg, args); va_end(args); } static xmlSAXHandler <API key> = { internalSubsetDebug, isStandaloneDebug, <API key>, <API key>, resolveEntityDebug, getEntityDebug, entityDeclDebug, notationDeclDebug, attributeDeclDebug, elementDeclDebug, <API key>, <API key>, startDocumentDebug, endDocumentDebug, startElementDebug, endElementDebug, referenceDebug, charactersDebug, <API key>, <API key>, commentDebug, warningDebug, errorDebug, fatalErrorDebug, <API key>, cdataDebug, NULL, 1, NULL, NULL, NULL, NULL }; xmlSAXHandlerPtr debugSAXHandler = &<API key>; static void parseSAXFile(char *filename) { htmlDocPtr doc = NULL; /* * Empty callbacks for checking */ #ifdef LIBXML_PUSH_ENABLED if (push) { FILE *f; f = fopen(filename, "rb"); if (f != NULL) { int res, size = 3; char chars[4096]; htmlParserCtxtPtr ctxt; /* if (repeat) */ size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = <API key>(emptySAXHandler, NULL, chars, res, filename, <API key>); while ((res = fread(chars, 1, size, f)) > 0) { htmlParseChunk(ctxt, chars, res, 0); } htmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); } if (doc != NULL) { fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); xmlFreeDoc(doc); } fclose(f); } if (!noout) { f = fopen(filename, "rb"); if (f != NULL) { int res, size = 3; char chars[4096]; htmlParserCtxtPtr ctxt; /* if (repeat) */ size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = <API key>(debugSAXHandler, NULL, chars, res, filename, <API key>); while ((res = fread(chars, 1, size, f)) > 0) { htmlParseChunk(ctxt, chars, res, 0); } htmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); } if (doc != NULL) { fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); xmlFreeDoc(doc); } fclose(f); } } } else { #endif /* LIBXML_PUSH_ENABLED */ doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL); if (doc != NULL) { fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); xmlFreeDoc(doc); } if (!noout) { /* * Debug callback */ doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL); if (doc != NULL) { fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); xmlFreeDoc(doc); } } #ifdef LIBXML_PUSH_ENABLED } #endif /* LIBXML_PUSH_ENABLED */ } static void parseAndPrintFile(char *filename) { htmlDocPtr doc = NULL; /* * build an HTML tree from a string; */ #ifdef LIBXML_PUSH_ENABLED if (push) { FILE *f; f = fopen(filename, "rb"); if (f != NULL) { int res, size = 3; char chars[4096]; htmlParserCtxtPtr ctxt; /* if (repeat) */ size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = <API key>(NULL, NULL, chars, res, filename, <API key>); while ((res = fread(chars, 1, size, f)) > 0) { htmlParseChunk(ctxt, chars, res, 0); } htmlParseChunk(ctxt, chars, 0, 1); doc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); } fclose(f); } } else { doc = htmlReadFile(filename, NULL, options); } #else doc = htmlReadFile(filename,NULL,options); #endif if (doc == NULL) { xmlGenericError(<API key>, "Could not parse %s\n", filename); } #ifdef LIBXML_TREE_ENABLED /* * test intermediate copy if needed. */ if (copy) { htmlDocPtr tmp; tmp = doc; doc = xmlCopyDoc(doc, 1); xmlFreeDoc(tmp); } #endif #ifdef <API key> /* * print it. */ if (!noout) { #ifdef <API key> if (!debug) { if (encoding) htmlSaveFileEnc("-", doc, encoding); else htmlDocDump(stdout, doc); } else <API key>(stdout, doc); #else if (encoding) htmlSaveFileEnc("-", doc, encoding); else htmlDocDump(stdout, doc); #endif } #endif /* <API key> */ /* * free it. */ xmlFreeDoc(doc); } int main(int argc, char **argv) { int i, count; int files = 0; for (i = 1; i < argc ; i++) { #ifdef <API key> if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) debug++; else #endif if ((!strcmp(argv[i], "-copy")) || (!strcmp(argv[i], "--copy"))) copy++; #ifdef LIBXML_PUSH_ENABLED else if ((!strcmp(argv[i], "-push")) || (!strcmp(argv[i], "--push"))) push++; #endif /* LIBXML_PUSH_ENABLED */ else if ((!strcmp(argv[i], "-sax")) || (!strcmp(argv[i], "--sax"))) sax++; else if ((!strcmp(argv[i], "-noout")) || (!strcmp(argv[i], "--noout"))) noout++; else if ((!strcmp(argv[i], "-repeat")) || (!strcmp(argv[i], "--repeat"))) repeat++; else if ((!strcmp(argv[i], "-encode")) || (!strcmp(argv[i], "--encode"))) { i++; encoding = argv[i]; } } for (i = 1; i < argc ; i++) { if ((!strcmp(argv[i], "-encode")) || (!strcmp(argv[i], "--encode"))) { i++; continue; } if (argv[i][0] != '-') { if (repeat) { for (count = 0;count < 100 * repeat;count++) { if (sax) parseSAXFile(argv[i]); else parseAndPrintFile(argv[i]); } } else { if (sax) parseSAXFile(argv[i]); else parseAndPrintFile(argv[i]); } files ++; } } if (files == 0) { printf("Usage : %s [--debug] [--copy] [--copy] HTMLfiles ...\n", argv[0]); printf("\tParse the HTML files and output the result of the parsing\n"); #ifdef <API key> printf("\t--debug : dump a debug tree of the in-memory document\n"); #endif printf("\t--copy : used to test the internal copy implementation\n"); printf("\t--sax : debug the sequence of SAX callbacks\n"); printf("\t--repeat : parse the file 100 times, for timing\n"); printf("\t--noout : do not print the result\n"); #ifdef LIBXML_PUSH_ENABLED printf("\t--push : use the push mode parser\n"); #endif /* LIBXML_PUSH_ENABLED */ printf("\t--encode encoding : output in the given encoding\n"); } xmlCleanupParser(); xmlMemoryDump(); return(0); } #else /* !LIBXML_HTML_ENABLED */ #include <stdio.h> int main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { printf("%s : HTML support not compiled in\n", argv[0]); return(0); } #endif
import calendar import datetime from email.utils import format_datetime as <API key> from django.utils.dates import ( MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR, ) from django.utils.regex_helper import _lazy_re_compile from django.utils.timezone import ( <API key>, <API key>, is_naive, make_aware, ) from django.utils.translation import gettext as _ re_formatchars = _lazy_re_compile(r'(?<!\\)([<API key>])') re_escaped = _lazy_re_compile(r'\\(.)') class Formatter: def format(self, formatstr): pieces = [] for i, piece in enumerate(re_formatchars.split(str(formatstr))): if i % 2: if type(self.data) is datetime.date and hasattr(TimeFormat, piece): raise TypeError( "The format for date objects may not contain " "time-related format specifiers (found '%s')." % piece ) pieces.append(str(getattr(self, piece)())) elif piece: pieces.append(re_escaped.sub(r'\1', piece)) return ''.join(pieces) class TimeFormat(Formatter): def __init__(self, obj): self.data = obj self.timezone = None # We only support timezone when formatting datetime objects, # not date objects (timezone information not appropriate), # or time objects (against established django policy). if isinstance(obj, datetime.datetime): if is_naive(obj): self.timezone = <API key>() else: self.timezone = obj.tzinfo @property def <API key>(self): return ( not self.timezone or <API key>(self.data, self.timezone) ) def a(self): "'a.m.' or 'p.m.'" if self.data.hour > 11: return _('p.m.') return _('a.m.') def A(self): "'AM' or 'PM'" if self.data.hour > 11: return _('PM') return _('AM') def e(self): """ Timezone name. If timezone information is not available, return an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: return self.data.tzname() or '' except NotImplementedError: pass return "" def f(self): hour = self.data.hour % 12 or 12 minute = self.data.minute return '%d:%02d' % (hour, minute) if minute else hour def g(self): "Hour, 12-hour format without leading zeros; i.e. '1' to '12'" return self.data.hour % 12 or 12 def G(self): "Hour, 24-hour format without leading zeros; i.e. '0' to '23'" return self.data.hour def h(self): "Hour, 12-hour format; i.e. '01' to '12'" return '%02d' % (self.data.hour % 12 or 12) def H(self): "Hour, 24-hour format; i.e. '00' to '23'" return '%02d' % self.data.hour def i(self): "Minutes; i.e. '00' to '59'" return '%02d' % self.data.minute def O(self): # NOQA: E743, E741 """ Difference to Greenwich time in hours; e.g. '+0200', '-0430'. If timezone information is not available, return an empty string. """ if self.<API key>: return "" seconds = self.Z() sign = '-' if seconds < 0 else '+' seconds = abs(seconds) return "%s%02d%02d" % (sign, seconds // 3600, (seconds // 60) % 60) def P(self): if self.data.minute == 0 and self.data.hour == 0: return _('midnight') if self.data.minute == 0 and self.data.hour == 12: return _('noon') return '%s %s' % (self.f(), self.a()) def s(self): "Seconds; i.e. '00' to '59'" return '%02d' % self.data.second def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, return an empty string. """ if self.<API key>: return "" return str(self.timezone.tzname(self.data)) def u(self): "Microseconds; i.e. '000000' to '999999'" return '%06d' % self.data.microsecond def Z(self): """ Time zone offset in seconds (i.e. '-43200' to '43200'). The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. If timezone information is not available, return an empty string. """ if self.<API key>: return "" offset = self.timezone.utcoffset(self.data) # `offset` is a datetime.timedelta. For negative values (to the west of # UTC) only days can be negative (days=-1) and seconds are always # positive. e.g. UTC-1 -> timedelta(days=-1, seconds=82800, microseconds=0) # Positive offsets have days=0 return offset.days * 86400 + offset.seconds class DateFormat(TimeFormat): def b(self): "Month, textual, 3 letters, lowercase; e.g. 'jan'" return MONTHS_3[self.data.month] def c(self): """ ISO 8601 Format Example : '2008-01-02T10:30:00.000123' """ return self.data.isoformat() def d(self): "Day of the month, 2 digits with leading zeros; i.e. '01' to '31'" return '%02d' % self.data.day def D(self): "Day of the week, textual, 3 letters; e.g. 'Fri'" return WEEKDAYS_ABBR[self.data.weekday()] def E(self): "Alternative month names as required by some locales. Proprietary extension." return MONTHS_ALT[self.data.month] def F(self): "Month, textual, long; e.g. 'January'" return MONTHS[self.data.month] def I(self): # NOQA: E743, E741 "'1' if daylight saving time, '0' otherwise." if self.<API key>: return '' return '1' if self.timezone.dst(self.data) else '0' def j(self): "Day of the month without leading zeros; i.e. '1' to '31'" return self.data.day def l(self): # NOQA: E743, E741 "Day of the week, textual, long; e.g. 'Friday'" return WEEKDAYS[self.data.weekday()] def L(self): "Boolean for whether it is a leap year; i.e. True or False" return calendar.isleap(self.data.year) def m(self): "Month; i.e. '01' to '12'" return '%02d' % self.data.month def M(self): "Month, textual, 3 letters; e.g. 'Jan'" return MONTHS_3[self.data.month].title() def n(self): "Month without leading zeros; i.e. '1' to '12'" return self.data.month def N(self): "Month abbreviation in Associated Press style. Proprietary extension." return MONTHS_AP[self.data.month] def o(self): "ISO 8601 year number matching the ISO week number (W)" return self.data.isocalendar()[0] def r(self): "RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'" if type(self.data) is datetime.date: raise TypeError( "The format for date objects may not contain time-related " "format specifiers (found 'r')." ) if is_naive(self.data): dt = make_aware(self.data, timezone=self.timezone) else: dt = self.data return <API key>(dt) def S(self): "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" if self.data.day in (11, 12, 13): # Special case return 'th' last = self.data.day % 10 if last == 1: return 'st' if last == 2: return 'nd' if last == 3: return 'rd' return 'th' def t(self): "Number of days in the given month; i.e. '28' to '31'" return '%02d' % calendar.monthrange(self.data.year, self.data.month)[1] def U(self): "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" value = self.data if not isinstance(value, datetime.datetime): value = datetime.datetime.combine(value, datetime.time.min) return int(value.timestamp()) def w(self): "Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)" return (self.data.weekday() + 1) % 7 def W(self): "ISO-8601 week number of year, weeks starting on Monday" return self.data.isocalendar()[1] def y(self): """Year, 2 digits with leading zeros; e.g. '99'.""" return '%02d' % (self.data.year % 100) def Y(self): """Year, 4 digits with leading zeros; e.g. '1999'.""" return '%04d' % self.data.year def z(self): """Day of the year, i.e. 1 to 366.""" return self.data.timetuple().tm_yday def format(value, format_string): "Convenience function" df = DateFormat(value) return df.format(format_string) def time_format(value, format_string): "Convenience function" tf = TimeFormat(value) return tf.format(format_string)
// This file is part of the glmark2 OpenGL (ES) 2.0 benchmark. // glmark2 is free software: you can redistribute it and/or modify it under the // version. // glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY // details. // Authors: // Jesse Barker // Alexandros Frantzis #ifndef <API key> #define <API key> #include <vector> #include "scene.h" class SceneCollection { public: SceneCollection(Canvas& canvas) { add_scenes(canvas); } ~SceneCollection() { Util::<API key>(scenes_); } void register_scenes() { for (std::vector<Scene*>::const_iterator iter = scenes_.begin(); iter != scenes_.end(); iter++) { Benchmark::register_scene(**iter); } } const std::vector<Scene*>& get() { return scenes_; } private: std::vector<Scene*> scenes_; // Creates all the available scenes and adds them to the supplied vector. // @param scenes the vector to add the scenes to // @param canvas the canvas to create the scenes with void add_scenes(Canvas& canvas) { scenes_.push_back(new SceneDefaultOptions(canvas)); scenes_.push_back(new SceneBuild(canvas)); scenes_.push_back(new SceneTexture(canvas)); scenes_.push_back(new SceneShading(canvas)); scenes_.push_back(new SceneConditionals(canvas)); scenes_.push_back(new SceneFunction(canvas)); scenes_.push_back(new SceneLoop(canvas)); scenes_.push_back(new SceneBump(canvas)); scenes_.push_back(new SceneEffect2D(canvas)); scenes_.push_back(new ScenePulsar(canvas)); scenes_.push_back(new SceneDesktop(canvas)); scenes_.push_back(new SceneBuffer(canvas)); scenes_.push_back(new SceneIdeas(canvas)); scenes_.push_back(new SceneTerrain(canvas)); scenes_.push_back(new SceneJellyfish(canvas)); scenes_.push_back(new SceneShadow(canvas)); scenes_.push_back(new SceneRefract(canvas)); scenes_.push_back(new SceneClear(canvas)); } }; #endif // <API key>
// REQUIRES: <API key> // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -o - < %s | FileCheck %s --check-prefix=PLAIN // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -ffunction-sections -o - < %s | FileCheck %s --check-prefix=FUNC_SECT // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT // Try again through a clang invocation of the ThinLTO backend. // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 %s -flto=thin -emit-llvm-bc -o %t.o // RUN: llvm-lto -thinlto -o %t %t.o // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s --check-prefix=DATA_SECT const int hello = 123; void world() {} // PLAIN-NOT: section // PLAIN: world: // PLAIN: section .rodata, // PLAIN: hello: // FUNC_SECT: section .text.world, // FUNC_SECT: world: // FUNC_SECT: section .rodata, // FUNC_SECT: hello: // DATA_SECT-NOT: .section // DATA_SECT: world: // DATA_SECT: .section .rodata.hello, // DATA_SECT: hello:
;***************************************************************************** ;* predict-a.asm: x86 intra prediction ;***************************************************************************** ;* Copyright (C) 2005-2016 x264 project ;* ;* Authors: Loren Merritt <lorenm@u.washington.edu> ;* Holger Lubitz <holger@lubitz.org> ;* Fiona Glaser <fiona@x264.com> ;* Henrik Gramner <henrik@gramner.com> ;* ;* 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 02111, USA. ;* ;* This program is also available under a commercial proprietary license. ;* For more information, contact us at licensing@x264.com. ;***************************************************************************** %include "x86inc.asm" %include "x86util.asm" SECTION_RODATA 32 pw_43210123: times 2 dw -3, -2, -1, 0, 1, 2, 3, 4 pw_m3: times 16 dw -3 pw_m7: times 16 dw -7 pb_00s_ff: times 8 db 0 pb_0s_ff: times 7 db 0 db 0xff shuf_fixtr: db 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7 shuf_nop: db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 shuf_hu: db 7,6,5,4,3,2,1,0,0,0,0,0,0,0,0,0 shuf_vr: db 2,4,6,8,9,10,11,12,13,14,15,0,1,3,5,7 pw_reverse: db 14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1 SECTION .text cextern pb_0 cextern pb_1 cextern pb_3 cextern pw_1 cextern pw_2 cextern pw_4 cextern pw_8 cextern pw_16 cextern pw_00ff cextern pw_pixel_max cextern pw_0to15 %macro STORE8 1 mova [r0+0*FDEC_STRIDEB], %1 mova [r0+1*FDEC_STRIDEB], %1 add r0, 4*FDEC_STRIDEB mova [r0-2*FDEC_STRIDEB], %1 mova [r0-1*FDEC_STRIDEB], %1 mova [r0+0*FDEC_STRIDEB], %1 mova [r0+1*FDEC_STRIDEB], %1 mova [r0+2*FDEC_STRIDEB], %1 mova [r0+3*FDEC_STRIDEB], %1 %endmacro %macro STORE16 1-4 %if %0 > 1 mov r1d, 2*%0 .loop: mova [r0+0*FDEC_STRIDEB+0*mmsize], %1 mova [r0+0*FDEC_STRIDEB+1*mmsize], %2 mova [r0+1*FDEC_STRIDEB+0*mmsize], %1 mova [r0+1*FDEC_STRIDEB+1*mmsize], %2 %ifidn %0, 4 mova [r0+0*FDEC_STRIDEB+2*mmsize], %3 mova [r0+0*FDEC_STRIDEB+3*mmsize], %4 mova [r0+1*FDEC_STRIDEB+2*mmsize], %3 mova [r0+1*FDEC_STRIDEB+3*mmsize], %4 add r0, 2*FDEC_STRIDEB %else ; %0 == 2 add r0, 4*FDEC_STRIDEB mova [r0-2*FDEC_STRIDEB+0*mmsize], %1 mova [r0-2*FDEC_STRIDEB+1*mmsize], %2 mova [r0-1*FDEC_STRIDEB+0*mmsize], %1 mova [r0-1*FDEC_STRIDEB+1*mmsize], %2 %endif dec r1d jg .loop %else ; %0 == 1 STORE8 %1 %if HIGH_BIT_DEPTH ; Different code paths to reduce code size add r0, 6*FDEC_STRIDEB mova [r0-2*FDEC_STRIDEB], %1 mova [r0-1*FDEC_STRIDEB], %1 mova [r0+0*FDEC_STRIDEB], %1 mova [r0+1*FDEC_STRIDEB], %1 add r0, 4*FDEC_STRIDEB mova [r0-2*FDEC_STRIDEB], %1 mova [r0-1*FDEC_STRIDEB], %1 mova [r0+0*FDEC_STRIDEB], %1 mova [r0+1*FDEC_STRIDEB], %1 %else add r0, 8*FDEC_STRIDE mova [r0-4*FDEC_STRIDE], %1 mova [r0-3*FDEC_STRIDE], %1 mova [r0-2*FDEC_STRIDE], %1 mova [r0-1*FDEC_STRIDE], %1 mova [r0+0*FDEC_STRIDE], %1 mova [r0+1*FDEC_STRIDE], %1 mova [r0+2*FDEC_STRIDE], %1 mova [r0+3*FDEC_STRIDE], %1 %endif ; HIGH_BIT_DEPTH %endif %endmacro %macro PRED_H_LOAD 2 ; reg, offset %if cpuflag(avx2) vpbroadcastpix %1, [r0+(%2)*<API key>] %elif HIGH_BIT_DEPTH movd %1, [r0+(%2)*FDEC_STRIDEB-4] SPLATW %1, %1, 1 %else SPLATB_LOAD %1, r0+(%2)*FDEC_STRIDE-1, m2 %endif %endmacro %macro PRED_H_STORE 3 ; reg, offset, width %assign %%w %3*SIZEOF_PIXEL %if %%w == 8 movq [r0+(%2)*FDEC_STRIDEB], %1 %else %assign %%i 0 %rep %%w/mmsize mova [r0+(%2)*FDEC_STRIDEB+%%i], %1 %assign %%i %%i+mmsize %endrep %endif %endmacro %macro PRED_H_4ROWS 2 ; width, inc_ptr PRED_H_LOAD m0, 0 PRED_H_LOAD m1, 1 PRED_H_STORE m0, 0, %1 PRED_H_STORE m1, 1, %1 PRED_H_LOAD m0, 2 %if %2 add r0, 4*FDEC_STRIDEB %endif PRED_H_LOAD m1, 3-4*%2 PRED_H_STORE m0, 2-4*%2, %1 PRED_H_STORE m1, 3-4*%2, %1 %endmacro ; dest, left, right, src, tmp ; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2 %macro PRED8x8_LOWPASS 4-5 %if HIGH_BIT_DEPTH paddw %2, %3 psrlw %2, 1 pavgw %1, %4, %2 %else mova %5, %2 pavgb %2, %3 pxor %3, %5 pand %3, [pb_1] psubusb %2, %3 pavgb %1, %4, %2 %endif %endmacro ; ; void predict_4x4_h( pixel *src ) ; %if HIGH_BIT_DEPTH INIT_XMM avx2 cglobal predict_4x4_h, 1,1 PRED_H_4ROWS 4, 0 RET %endif ; ; void predict_4x4_ddl( pixel *src ) ; %macro PREDICT_4x4_DDL 0 cglobal predict_4x4_ddl, 1,1 movu m1, [r0-FDEC_STRIDEB] PSLLPIX m2, m1, 1 mova m0, m1 %if HIGH_BIT_DEPTH PSRLPIX m1, m1, 1 pshufhw m1, m1, q2210 %else pxor m1, m2 PSRLPIX m1, m1, 1 pxor m1, m0 %endif PRED8x8_LOWPASS m0, m2, m1, m0, m3 %assign Y 0 %rep 4 PSRLPIX m0, m0, 1 movh [r0+Y*FDEC_STRIDEB], m0 %assign Y (Y+1) %endrep RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_4x4_DDL INIT_XMM avx PREDICT_4x4_DDL INIT_MMX mmx2 cglobal predict_4x4_ddl, 1,2 movu m1, [r0-FDEC_STRIDEB+4] PRED8x8_LOWPASS m0, m1, [r0-FDEC_STRIDEB+0], [r0-FDEC_STRIDEB+2] mova m3, [r0-FDEC_STRIDEB+8] mova [r0+0*FDEC_STRIDEB], m0 pshufw m4, m3, q3321 PRED8x8_LOWPASS m2, m4, [r0-FDEC_STRIDEB+6], m3 mova [r0+3*FDEC_STRIDEB], m2 pshufw m1, m0, q0021 punpckldq m1, m2 mova [r0+1*FDEC_STRIDEB], m1 psllq m0, 16 PALIGNR m2, m0, 6, m0 mova [r0+2*FDEC_STRIDEB], m2 RET %else ; !HIGH_BIT_DEPTH INIT_MMX mmx2 PREDICT_4x4_DDL %endif ; ; void predict_4x4_vr( pixel *src ) ; %if HIGH_BIT_DEPTH == 0 INIT_MMX ssse3 cglobal predict_4x4_vr, 1,1 movd m1, [r0-1*FDEC_STRIDEB] ; ........t3t2t1t0 mova m4, m1 palignr m1, [r0-1*FDEC_STRIDEB-8], 7 ; ......t3t2t1t0lt pavgb m4, m1 palignr m1, [r0+0*FDEC_STRIDEB-8], 7 ; ....t3t2t1t0ltl0 mova m0, m1 palignr m1, [r0+1*FDEC_STRIDEB-8], 7 ; ..t3t2t1t0ltl0l1 mova m2, m1 palignr m1, [r0+2*FDEC_STRIDEB-8], 7 ; t3t2t1t0ltl0l1l2 PRED8x8_LOWPASS m2, m0, m1, m2, m3 pshufw m0, m2, 0 psrlq m2, 16 movd [r0+0*FDEC_STRIDEB], m4 palignr m4, m0, 7 movd [r0+1*FDEC_STRIDEB], m2 psllq m0, 8 movd [r0+2*FDEC_STRIDEB], m4 palignr m2, m0, 7 movd [r0+3*FDEC_STRIDEB], m2 RET %endif ; !HIGH_BIT_DEPTH ; ; void predict_4x4_ddr( pixel *src ) ; %macro PREDICT_4x4 4 cglobal predict_4x4_ddr, 1,1 %if HIGH_BIT_DEPTH movu m2, [r0-1*FDEC_STRIDEB-8] pinsrw m2, [r0+0*FDEC_STRIDEB-2], 2 pinsrw m2, [r0+1*FDEC_STRIDEB-2], 1 pinsrw m2, [r0+2*FDEC_STRIDEB-2], 0 movhps m3, [r0+3*FDEC_STRIDEB-8] %else ; !HIGH_BIT_DEPTH movd m0, [r0+2*FDEC_STRIDEB-4] movd m1, [r0+0*FDEC_STRIDEB-4] punpcklbw m0, [r0+1*FDEC_STRIDEB-4] punpcklbw m1, [r0-1*FDEC_STRIDEB-4] punpckhwd m0, m1 movd m2, [r0-1*FDEC_STRIDEB] %if cpuflag(ssse3) palignr m2, m0, 4 %else psllq m2, 32 punpckhdq m0, m2 SWAP 2, 0 %endif movd m3, [r0+3*FDEC_STRIDEB-4] psllq m3, 32 %endif ; !HIGH_BIT_DEPTH PSRLPIX m1, m2, 1 mova m0, m2 PALIGNR m2, m3, 7*SIZEOF_PIXEL, m3 PRED8x8_LOWPASS m0, m2, m1, m0, m3 %assign Y 3 movh [r0+Y*FDEC_STRIDEB], m0 %rep 3 %assign Y (Y-1) PSRLPIX m0, m0, 1 movh [r0+Y*FDEC_STRIDEB], m0 %endrep RET ; ; void predict_4x4_vr( pixel *src ) ; cglobal predict_4x4_vr, 1,1 %if HIGH_BIT_DEPTH movu m1, [r0-1*FDEC_STRIDEB-8] pinsrw m1, [r0+0*FDEC_STRIDEB-2], 2 pinsrw m1, [r0+1*FDEC_STRIDEB-2], 1 pinsrw m1, [r0+2*FDEC_STRIDEB-2], 0 %else ; !HIGH_BIT_DEPTH movd m0, [r0+2*FDEC_STRIDEB-4] movd m1, [r0+0*FDEC_STRIDEB-4] punpcklbw m0, [r0+1*FDEC_STRIDEB-4] punpcklbw m1, [r0-1*FDEC_STRIDEB-4] punpckhwd m0, m1 movd m1, [r0-1*FDEC_STRIDEB] %if cpuflag(ssse3) palignr m1, m0, 4 %else psllq m1, 32 punpckhdq m0, m1 SWAP 1, 0 %endif %endif ; !HIGH_BIT_DEPTH PSRLPIX m2, m1, 1 PSRLPIX m0, m1, 2 pavg%1 m4, m1, m2 PSRLPIX m4, m4, 3 PRED8x8_LOWPASS m2, m0, m1, m2, m3 PSLLPIX m0, m2, 6 PSRLPIX m2, m2, 2 movh [r0+0*FDEC_STRIDEB], m4 PALIGNR m4, m0, 7*SIZEOF_PIXEL, m3 movh [r0+1*FDEC_STRIDEB], m2 PSLLPIX m0, m0, 1 movh [r0+2*FDEC_STRIDEB], m4 PALIGNR m2, m0, 7*SIZEOF_PIXEL, m0 movh [r0+3*FDEC_STRIDEB], m2 RET ; ; void predict_4x4_hd( pixel *src ) ; cglobal predict_4x4_hd, 1,1 %if HIGH_BIT_DEPTH movu m1, [r0-1*FDEC_STRIDEB-8] PSLLPIX m1, m1, 1 pinsrw m1, [r0+0*FDEC_STRIDEB-2], 3 pinsrw m1, [r0+1*FDEC_STRIDEB-2], 2 pinsrw m1, [r0+2*FDEC_STRIDEB-2], 1 pinsrw m1, [r0+3*FDEC_STRIDEB-2], 0 %else movd m0, [r0-1*FDEC_STRIDEB-4] ; lt .. punpckldq m0, [r0-1*FDEC_STRIDEB] ; t3 t2 t1 t0 lt .. .. .. PSLLPIX m0, m0, 1 ; t2 t1 t0 lt .. .. .. .. movd m1, [r0+3*FDEC_STRIDEB-4] ; l3 punpcklbw m1, [r0+2*FDEC_STRIDEB-4] ; l2 l3 movd m2, [r0+1*FDEC_STRIDEB-4] ; l1 punpcklbw m2, [r0+0*FDEC_STRIDEB-4] ; l0 l1 punpckh%3 m1, m2 ; l0 l1 l2 l3 punpckh%4 m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3 %endif PSRLPIX m2, m1, 1 ; .. t2 t1 t0 lt l0 l1 l2 PSRLPIX m0, m1, 2 ; .. .. t2 t1 t0 lt l0 l1 pavg%1 m5, m1, m2 PRED8x8_LOWPASS m3, m1, m0, m2, m4 punpckl%2 m5, m3 PSRLPIX m3, m3, 4 PALIGNR m3, m5, 6*SIZEOF_PIXEL, m4 %assign Y 3 movh [r0+Y*FDEC_STRIDEB], m5 %rep 2 %assign Y (Y-1) PSRLPIX m5, m5, 2 movh [r0+Y*FDEC_STRIDEB], m5 %endrep movh [r0+0*FDEC_STRIDEB], m3 RET %endmacro ; PREDICT_4x4 ; ; void predict_4x4_ddr( pixel *src ) ; %if HIGH_BIT_DEPTH INIT_MMX mmx2 cglobal predict_4x4_ddr, 1,1 mova m0, [r0+1*FDEC_STRIDEB-8] punpckhwd m0, [r0+0*FDEC_STRIDEB-8] mova m3, [r0+3*FDEC_STRIDEB-8] punpckhwd m3, [r0+2*FDEC_STRIDEB-8] punpckhdq m3, m0 pshufw m0, m3, q3321 pinsrw m0, [r0-1*FDEC_STRIDEB-2], 3 pshufw m1, m0, q3321 PRED8x8_LOWPASS m0, m1, m3, m0 movq [r0+3*FDEC_STRIDEB], m0 movq m2, [r0-1*FDEC_STRIDEB-0] pshufw m4, m2, q2100 pinsrw m4, [r0-1*FDEC_STRIDEB-2], 0 movq m1, m4 PALIGNR m4, m3, 6, m3 PRED8x8_LOWPASS m1, m4, m2, m1 movq [r0+0*FDEC_STRIDEB], m1 pshufw m2, m0, q3321 punpckldq m2, m1 psllq m0, 16 PALIGNR m1, m0, 6, m0 movq [r0+1*FDEC_STRIDEB], m1 movq [r0+2*FDEC_STRIDEB], m2 movd [r0+3*FDEC_STRIDEB+4], m1 RET ; ; void predict_4x4_hd( pixel *src ) ; cglobal predict_4x4_hd, 1,1 mova m0, [r0+1*FDEC_STRIDEB-8] punpckhwd m0, [r0+0*FDEC_STRIDEB-8] mova m1, [r0+3*FDEC_STRIDEB-8] punpckhwd m1, [r0+2*FDEC_STRIDEB-8] punpckhdq m1, m0 mova m0, m1 movu m3, [r0-1*FDEC_STRIDEB-2] pshufw m4, m1, q0032 mova m7, m3 punpckldq m4, m3 PALIGNR m3, m1, 2, m2 PRED8x8_LOWPASS m2, m4, m1, m3 pavgw m0, m3 punpcklwd m5, m0, m2 punpckhwd m4, m0, m2 mova [r0+3*FDEC_STRIDEB], m5 mova [r0+1*FDEC_STRIDEB], m4 psrlq m5, 32 punpckldq m5, m4 mova [r0+2*FDEC_STRIDEB], m5 pshufw m4, m7, q2100 mova m6, [r0-1*FDEC_STRIDEB+0] pinsrw m4, [r0+0*FDEC_STRIDEB-2], 0 PRED8x8_LOWPASS m3, m4, m6, m7 PALIGNR m3, m0, 6, m0 mova [r0+0*FDEC_STRIDEB], m3 RET INIT_XMM sse2 PREDICT_4x4 w, wd, dq, qdq INIT_XMM ssse3 PREDICT_4x4 w, wd, dq, qdq INIT_XMM avx PREDICT_4x4 w, wd, dq, qdq %else ; !HIGH_BIT_DEPTH INIT_MMX mmx2 PREDICT_4x4 b, bw, wd, dq INIT_MMX ssse3 %define <API key> <API key> PREDICT_4x4 b, bw, wd, dq %endif ; ; void predict_4x4_hu( pixel *src ) ; %if HIGH_BIT_DEPTH INIT_MMX cglobal predict_4x4_hu_mmx2, 1,1 movq m0, [r0+0*FDEC_STRIDEB-8] punpckhwd m0, [r0+1*FDEC_STRIDEB-8] movq m1, [r0+2*FDEC_STRIDEB-8] punpckhwd m1, [r0+3*FDEC_STRIDEB-8] punpckhdq m0, m1 pshufw m1, m1, q3333 movq [r0+3*FDEC_STRIDEB], m1 pshufw m3, m0, q3321 pshufw m4, m0, q3332 pavgw m2, m0, m3 PRED8x8_LOWPASS m3, m0, m4, m3 punpcklwd m4, m2, m3 mova [r0+0*FDEC_STRIDEB], m4 psrlq m2, 16 psrlq m3, 16 punpcklwd m2, m3 mova [r0+1*FDEC_STRIDEB], m2 punpckhdq m2, m1 mova [r0+2*FDEC_STRIDEB], m2 RET %else ; !HIGH_BIT_DEPTH INIT_MMX cglobal predict_4x4_hu_mmx2, 1,1 movd m1, [r0+0*FDEC_STRIDEB-4] punpcklbw m1, [r0+1*FDEC_STRIDEB-4] movd m0, [r0+2*FDEC_STRIDEB-4] punpcklbw m0, [r0+3*FDEC_STRIDEB-4] punpckhwd m1, m0 movq m0, m1 punpckhbw m1, m1 pshufw m1, m1, q3333 punpckhdq m0, m1 movq m2, m0 movq m3, m0 movq m5, m0 psrlq m3, 8 psrlq m2, 16 pavgb m5, m3 PRED8x8_LOWPASS m3, m0, m2, m3, m4 movd [r0+3*FDEC_STRIDEB], m1 punpcklbw m5, m3 movd [r0+0*FDEC_STRIDEB], m5 psrlq m5, 16 movd [r0+1*FDEC_STRIDEB], m5 psrlq m5, 16 movd [r0+2*FDEC_STRIDEB], m5 RET %endif ; HIGH_BIT_DEPTH ; ; void predict_4x4_vl( pixel *src ) ; %macro PREDICT_4x4_V1 1 cglobal predict_4x4_vl, 1,1 movu m1, [r0-FDEC_STRIDEB] PSRLPIX m3, m1, 1 PSRLPIX m2, m1, 2 pavg%1 m4, m3, m1 PRED8x8_LOWPASS m0, m1, m2, m3, m5 movh [r0+0*FDEC_STRIDEB], m4 movh [r0+1*FDEC_STRIDEB], m0 PSRLPIX m4, m4, 1 PSRLPIX m0, m0, 1 movh [r0+2*FDEC_STRIDEB], m4 movh [r0+3*FDEC_STRIDEB], m0 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_4x4_V1 w INIT_XMM avx PREDICT_4x4_V1 w INIT_MMX mmx2 cglobal predict_4x4_vl, 1,4 mova m1, [r0-FDEC_STRIDEB+0] mova m2, [r0-FDEC_STRIDEB+8] mova m0, m2 PALIGNR m2, m1, 4, m4 PALIGNR m0, m1, 2, m4 mova m3, m0 pavgw m3, m1 mova [r0+0*FDEC_STRIDEB], m3 psrlq m3, 16 mova [r0+2*FDEC_STRIDEB], m3 PRED8x8_LOWPASS m0, m1, m2, m0 mova [r0+1*FDEC_STRIDEB], m0 psrlq m0, 16 mova [r0+3*FDEC_STRIDEB], m0 movzx r1d, word [r0-FDEC_STRIDEB+ 8] movzx r2d, word [r0-FDEC_STRIDEB+10] movzx r3d, word [r0-FDEC_STRIDEB+12] lea r1d, [r1+r2+1] add r3d, r2d lea r3d, [r3+r1+1] shr r1d, 1 shr r3d, 2 mov [r0+2*FDEC_STRIDEB+6], r1w mov [r0+3*FDEC_STRIDEB+6], r3w RET %else ; !HIGH_BIT_DEPTH INIT_MMX mmx2 PREDICT_4x4_V1 b %endif ; ; void predict_4x4_dc( pixel *src ) ; INIT_MMX mmx2 %if HIGH_BIT_DEPTH cglobal predict_4x4_dc, 1,1 mova m2, [r0+0*FDEC_STRIDEB-4*SIZEOF_PIXEL] paddw m2, [r0+1*FDEC_STRIDEB-4*SIZEOF_PIXEL] paddw m2, [r0+2*FDEC_STRIDEB-4*SIZEOF_PIXEL] paddw m2, [r0+3*FDEC_STRIDEB-4*SIZEOF_PIXEL] psrlq m2, 48 mova m0, [r0-FDEC_STRIDEB] HADDW m0, m1 paddw m0, [pw_4] paddw m0, m2 psrlw m0, 3 SPLATW m0, m0 mova [r0+0*FDEC_STRIDEB], m0 mova [r0+1*FDEC_STRIDEB], m0 mova [r0+2*FDEC_STRIDEB], m0 mova [r0+3*FDEC_STRIDEB], m0 RET %else ; !HIGH_BIT_DEPTH cglobal predict_4x4_dc, 1,4 pxor mm7, mm7 movd mm0, [r0-FDEC_STRIDEB] psadbw mm0, mm7 movd r3d, mm0 movzx r1d, byte [r0-1] %assign Y 1 %rep 3 movzx r2d, byte [r0+FDEC_STRIDEB*Y-1] add r1d, r2d %assign Y Y+1 %endrep lea r1d, [r1+r3+4] shr r1d, 3 imul r1d, 0x01010101 mov [r0+FDEC_STRIDEB*0], r1d mov [r0+FDEC_STRIDEB*1], r1d mov [r0+FDEC_STRIDEB*2], r1d mov [r0+FDEC_STRIDEB*3], r1d RET %endif ; HIGH_BIT_DEPTH %macro PREDICT_FILTER 4 ; ;void predict_8x8_filter( pixel *src, pixel edge[36], int i_neighbor, int i_filters ) ; cglobal predict_8x8_filter, 4,6,6 add r0, 0x58*SIZEOF_PIXEL %define src r0-0x58*SIZEOF_PIXEL %if ARCH_X86_64 == 0 mov r4, r1 %define t1 r4 %define t4 r1 %else %define t1 r1 %define t4 r4 %endif test r3b, 1 je .check_top mov t4d, r2d and t4d, 8 neg t4 mova m0, [src+0*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%1%2 m0, [src+0*FDEC_STRIDEB-8*SIZEOF_PIXEL+t4*(FDEC_STRIDEB/8)] mova m1, [src+2*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%1%2 m1, [src+1*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%2%3 m1, m0 mova m2, [src+4*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%1%2 m2, [src+3*FDEC_STRIDEB-8*SIZEOF_PIXEL] mova m3, [src+6*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%1%2 m3, [src+5*FDEC_STRIDEB-8*SIZEOF_PIXEL] punpckh%2%3 m3, m2 punpckh%3%4 m3, m1 mova m0, [src+7*FDEC_STRIDEB-8*SIZEOF_PIXEL] mova m1, [src-1*FDEC_STRIDEB] PALIGNR m4, m3, m0, 7*SIZEOF_PIXEL, m0 PALIGNR m1, m1, m3, 1*SIZEOF_PIXEL, m2 PRED8x8_LOWPASS m3, m1, m4, m3, m5 mova [t1+8*SIZEOF_PIXEL], m3 movzx t4d, pixel [src+7*FDEC_STRIDEB-1*SIZEOF_PIXEL] movzx r5d, pixel [src+6*FDEC_STRIDEB-1*SIZEOF_PIXEL] lea t4d, [t4*3+2] add t4d, r5d shr t4d, 2 mov [t1+7*SIZEOF_PIXEL], t4%1 mov [t1+6*SIZEOF_PIXEL], t4%1 test r3b, 2 je .done .check_top: %if SIZEOF_PIXEL==1 && cpuflag(ssse3) INIT_XMM cpuname movu m3, [src-1*FDEC_STRIDEB] movhps m0, [src-1*FDEC_STRIDEB-8] test r2b, 8 je .fix_lt_2 .do_top: and r2d, 4 %ifdef PIC lea r3, [shuf_fixtr] pshufb m3, [r3+r2*4] %else pshufb m3, [shuf_fixtr+r2*4] ; neighbor&MB_TOPRIGHT ? shuf_nop : shuf_fixtr %endif psrldq m1, m3, 15 PALIGNR m2, m3, m0, 15, m0 PALIGNR m1, m3, 1, m5 PRED8x8_LOWPASS m0, m2, m1, m3, m5 mova [t1+16*SIZEOF_PIXEL], m0 psrldq m0, 15 movd [t1+32*SIZEOF_PIXEL], m0 .done: REP_RET .fix_lt_2: pslldq m0, m3, 15 jmp .do_top %else mova m0, [src-1*FDEC_STRIDEB-8*SIZEOF_PIXEL] mova m3, [src-1*FDEC_STRIDEB] mova m1, [src-1*FDEC_STRIDEB+8*SIZEOF_PIXEL] test r2b, 8 je .fix_lt_2 test r2b, 4 je .fix_tr_1 .do_top: PALIGNR m2, m3, m0, 7*SIZEOF_PIXEL, m0 PALIGNR m0, m1, m3, 1*SIZEOF_PIXEL, m5 PRED8x8_LOWPASS m4, m2, m0, m3, m5 mova [t1+16*SIZEOF_PIXEL], m4 test r3b, 4 je .done PSRLPIX m5, m1, 7 PALIGNR m2, m1, m3, 7*SIZEOF_PIXEL, m3 PALIGNR m5, m1, 1*SIZEOF_PIXEL, m4 PRED8x8_LOWPASS m0, m2, m5, m1, m4 mova [t1+24*SIZEOF_PIXEL], m0 PSRLPIX m0, m0, 7 movd [t1+32*SIZEOF_PIXEL], m0 .done: REP_RET .fix_lt_2: PSLLPIX m0, m3, 7 test r2b, 4 jne .do_top .fix_tr_1: punpckh%1%2 m1, m3, m3 pshuf%2 m1, m1, q3333 jmp .do_top %endif %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_FILTER w, d, q, dq INIT_XMM ssse3 PREDICT_FILTER w, d, q, dq INIT_XMM avx PREDICT_FILTER w, d, q, dq %else INIT_MMX mmx2 PREDICT_FILTER b, w, d, q INIT_MMX ssse3 PREDICT_FILTER b, w, d, q %endif ; ; void predict_8x8_v( pixel *src, pixel *edge ) ; %macro PREDICT_8x8_V 0 cglobal predict_8x8_v, 2,2 mova m0, [r1+16*SIZEOF_PIXEL] STORE8 m0 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse PREDICT_8x8_V %else INIT_MMX mmx2 PREDICT_8x8_V %endif ; ; void predict_8x8_h( pixel *src, pixel edge[36] ) ; %macro PREDICT_8x8_H 2 cglobal predict_8x8_h, 2,2 movu m1, [r1+7*SIZEOF_PIXEL] add r0, 4*FDEC_STRIDEB punpckl%1 m2, m1, m1 punpckh%1 m1, m1 %assign Y 0 %rep 8 %assign i 1+Y/4 SPLAT%2 m0, m %+ i, (3-Y)&3 mova [r0+(Y-4)*FDEC_STRIDEB], m0 %assign Y Y+1 %endrep RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_H wd, D %else INIT_MMX mmx2 PREDICT_8x8_H bw, W %endif ; ; void predict_8x8_dc( pixel *src, pixel *edge ); ; %if HIGH_BIT_DEPTH INIT_XMM sse2 cglobal predict_8x8_dc, 2,2 movu m0, [r1+14] paddw m0, [r1+32] HADDW m0, m1 paddw m0, [pw_8] psrlw m0, 4 SPLATW m0, m0 STORE8 m0 RET %else ; !HIGH_BIT_DEPTH INIT_MMX mmx2 cglobal predict_8x8_dc, 2,2 pxor mm0, mm0 pxor mm1, mm1 psadbw mm0, [r1+7] psadbw mm1, [r1+16] paddw mm0, [pw_8] paddw mm0, mm1 psrlw mm0, 4 pshufw mm0, mm0, 0 packuswb mm0, mm0 STORE8 mm0 RET %endif ; HIGH_BIT_DEPTH ; ; void predict_8x8_dc_top ( pixel *src, pixel *edge ); ; void predict_8x8_dc_left( pixel *src, pixel *edge ); ; %if HIGH_BIT_DEPTH %macro PREDICT_8x8_DC 3 cglobal %1, 2,2 %3 m0, [r1+%2] HADDW m0, m1 paddw m0, [pw_4] psrlw m0, 3 SPLATW m0, m0 STORE8 m0 RET %endmacro INIT_XMM sse2 PREDICT_8x8_DC predict_8x8_dc_top , 32, mova PREDICT_8x8_DC predict_8x8_dc_left, 14, movu %else ; !HIGH_BIT_DEPTH %macro PREDICT_8x8_DC 2 cglobal %1, 2,2 pxor mm0, mm0 psadbw mm0, [r1+%2] paddw mm0, [pw_4] psrlw mm0, 3 pshufw mm0, mm0, 0 packuswb mm0, mm0 STORE8 mm0 RET %endmacro INIT_MMX PREDICT_8x8_DC <API key>, 16 PREDICT_8x8_DC <API key>, 7 %endif ; HIGH_BIT_DEPTH ; sse2 is faster even on amd for 8-bit, so there's no sense in spending exe ; size on the 8-bit mmx functions below if we know sse2 is available. %macro PREDICT_8x8_DDLR 0 ; ; void predict_8x8_ddl( pixel *src, pixel *edge ) ; cglobal predict_8x8_ddl, 2,2,7 mova m0, [r1+16*SIZEOF_PIXEL] mova m1, [r1+24*SIZEOF_PIXEL] %if cpuflag(cache64) movd m5, [r1+32*SIZEOF_PIXEL] palignr m3, m1, m0, 1*SIZEOF_PIXEL palignr m5, m5, m1, 1*SIZEOF_PIXEL palignr m4, m1, m0, 7*SIZEOF_PIXEL %else movu m3, [r1+17*SIZEOF_PIXEL] movu m4, [r1+23*SIZEOF_PIXEL] movu m5, [r1+25*SIZEOF_PIXEL] %endif PSLLPIX m2, m0, 1 add r0, FDEC_STRIDEB*4 PRED8x8_LOWPASS m0, m2, m3, m0, m6 PRED8x8_LOWPASS m1, m4, m5, m1, m6 mova [r0+3*FDEC_STRIDEB], m1 %assign Y 2 %rep 6 PALIGNR m1, m0, 7*SIZEOF_PIXEL, m2 PSLLPIX m0, m0, 1 mova [r0+Y*FDEC_STRIDEB], m1 %assign Y (Y-1) %endrep PALIGNR m1, m0, 7*SIZEOF_PIXEL, m0 mova [r0+Y*FDEC_STRIDEB], m1 RET ; ; void predict_8x8_ddr( pixel *src, pixel *edge ) ; cglobal predict_8x8_ddr, 2,2,7 add r0, FDEC_STRIDEB*4 mova m0, [r1+ 8*SIZEOF_PIXEL] mova m1, [r1+16*SIZEOF_PIXEL] ; edge[] is 32byte aligned, so some of the unaligned loads are known to be not cachesplit movu m2, [r1+ 7*SIZEOF_PIXEL] movu m5, [r1+17*SIZEOF_PIXEL] %if cpuflag(cache64) palignr m3, m1, m0, 1*SIZEOF_PIXEL palignr m4, m1, m0, 7*SIZEOF_PIXEL %else movu m3, [r1+ 9*SIZEOF_PIXEL] movu m4, [r1+15*SIZEOF_PIXEL] %endif PRED8x8_LOWPASS m0, m2, m3, m0, m6 PRED8x8_LOWPASS m1, m4, m5, m1, m6 mova [r0+3*FDEC_STRIDEB], m0 %assign Y -4 %rep 6 PALIGNR m1, m0, 7*SIZEOF_PIXEL, m2 PSLLPIX m0, m0, 1 mova [r0+Y*FDEC_STRIDEB], m1 %assign Y (Y+1) %endrep PALIGNR m1, m0, 7*SIZEOF_PIXEL, m0 mova [r0+Y*FDEC_STRIDEB], m1 RET %endmacro ; PREDICT_8x8_DDLR %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_DDLR INIT_XMM ssse3 PREDICT_8x8_DDLR INIT_XMM ssse3, cache64 PREDICT_8x8_DDLR %elif ARCH_X86_64 == 0 INIT_MMX mmx2 PREDICT_8x8_DDLR %endif ; ; void predict_8x8_hu( pixel *src, pixel *edge ) ; %macro PREDICT_8x8_HU 2 cglobal predict_8x8_hu, 2,2,8 add r0, 4*FDEC_STRIDEB %if HIGH_BIT_DEPTH %if cpuflag(ssse3) movu m5, [r1+7*SIZEOF_PIXEL] pshufb m5, [pw_reverse] %else movq m6, [r1+7*SIZEOF_PIXEL] movq m5, [r1+11*SIZEOF_PIXEL] pshuflw m6, m6, q0123 pshuflw m5, m5, q0123 movlhps m5, m6 %endif ; cpuflag psrldq m2, m5, 2 pshufd m3, m5, q0321 pshufhw m2, m2, q2210 pshufhw m3, m3, q1110 pavgw m4, m5, m2 %else ; !HIGH_BIT_DEPTH movu m1, [r1+7*SIZEOF_PIXEL] ; l0 l1 l2 l3 l4 l5 l6 l7 pshufw m0, m1, q0123 ; l6 l7 l4 l5 l2 l3 l0 l1 psllq m1, 56 ; l7 .. .. .. .. .. .. .. mova m2, m0 psllw m0, 8 psrlw m2, 8 por m2, m0 mova m3, m2 mova m4, m2 mova m5, m2 ; l7 l6 l5 l4 l3 l2 l1 l0 psrlq m3, 16 psrlq m2, 8 por m2, m1 ; l7 l7 l6 l5 l4 l3 l2 l1 punpckhbw m1, m1 por m3, m1 ; l7 l7 l7 l6 l5 l4 l3 l2 pavgb m4, m2 %endif ; !HIGH_BIT_DEPTH PRED8x8_LOWPASS m2, m3, m5, m2, m6 punpckh%2 m0, m4, m2 ; p8 p7 p6 p5 punpckl%2 m4, m2 ; p4 p3 p2 p1 PALIGNR m5, m0, m4, 2*SIZEOF_PIXEL, m3 pshuf%1 m1, m0, q3321 PALIGNR m6, m0, m4, 4*SIZEOF_PIXEL, m3 pshuf%1 m2, m0, q3332 PALIGNR m7, m0, m4, 6*SIZEOF_PIXEL, m3 pshuf%1 m3, m0, q3333 mova [r0-4*FDEC_STRIDEB], m4 mova [r0-3*FDEC_STRIDEB], m5 mova [r0-2*FDEC_STRIDEB], m6 mova [r0-1*FDEC_STRIDEB], m7 mova [r0+0*FDEC_STRIDEB], m0 mova [r0+1*FDEC_STRIDEB], m1 mova [r0+2*FDEC_STRIDEB], m2 mova [r0+3*FDEC_STRIDEB], m3 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_HU d, wd INIT_XMM ssse3 PREDICT_8x8_HU d, wd INIT_XMM avx PREDICT_8x8_HU d, wd %elif ARCH_X86_64 == 0 INIT_MMX mmx2 PREDICT_8x8_HU w, bw %endif ; ; void predict_8x8_vr( pixel *src, pixel *edge ) ; %macro PREDICT_8x8_VR 1 cglobal predict_8x8_vr, 2,3 mova m2, [r1+16*SIZEOF_PIXEL] %ifidn cpuname, ssse3 mova m0, [r1+8*SIZEOF_PIXEL] palignr m3, m2, m0, 7*SIZEOF_PIXEL palignr m1, m2, m0, 6*SIZEOF_PIXEL %else movu m3, [r1+15*SIZEOF_PIXEL] movu m1, [r1+14*SIZEOF_PIXEL] %endif pavg%1 m4, m3, m2 add r0, FDEC_STRIDEB*4 PRED8x8_LOWPASS m3, m1, m2, m3, m5 mova [r0-4*FDEC_STRIDEB], m4 mova [r0-3*FDEC_STRIDEB], m3 mova m1, [r1+8*SIZEOF_PIXEL] PSLLPIX m0, m1, 1 PSLLPIX m2, m1, 2 PRED8x8_LOWPASS m0, m1, m2, m0, m6 %assign Y -2 %rep 5 PALIGNR m4, m0, 7*SIZEOF_PIXEL, m5 mova [r0+Y*FDEC_STRIDEB], m4 PSLLPIX m0, m0, 1 SWAP 3, 4 %assign Y (Y+1) %endrep PALIGNR m4, m0, 7*SIZEOF_PIXEL, m0 mova [r0+Y*FDEC_STRIDEB], m4 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_VR w INIT_XMM ssse3 PREDICT_8x8_VR w INIT_XMM avx PREDICT_8x8_VR w %elif ARCH_X86_64 == 0 INIT_MMX mmx2 PREDICT_8x8_VR b %endif %macro LOAD_PLANE_ARGS 0 %if cpuflag(avx2) && ARCH_X86_64 == 0 vpbroadcastw m0, r1m vpbroadcastw m2, r2m vpbroadcastw m4, r3m %elif mmsize == 8 ; MMX is only used on x86_32 SPLATW m0, r1m SPLATW m2, r2m SPLATW m4, r3m %else movd xm0, r1m movd xm2, r2m movd xm4, r3m SPLATW m0, xm0 SPLATW m2, xm2 SPLATW m4, xm4 %endif %endmacro ; ; void predict_8x8c_p_core( uint8_t *src, int i00, int b, int c ) ; %if ARCH_X86_64 == 0 && HIGH_BIT_DEPTH == 0 %macro <API key> 1 cglobal predict_8x%1c_p_core, 1,2 LOAD_PLANE_ARGS movq m1, m2 pmullw m2, [pw_0to15] psllw m1, 2 paddsw m0, m2 ; m0 = {i+0*b, i+1*b, i+2*b, i+3*b} paddsw m1, m0 ; m1 = {i+4*b, i+5*b, i+6*b, i+7*b} mov r1d, %1 ALIGN 4 .loop: movq m5, m0 movq m6, m1 psraw m5, 5 psraw m6, 5 packuswb m5, m6 movq [r0], m5 paddsw m0, m4 paddsw m1, m4 add r0, FDEC_STRIDE dec r1d jg .loop RET %endmacro ; <API key> INIT_MMX mmx2 <API key> 8 <API key> 16 %endif ; !ARCH_X86_64 && !HIGH_BIT_DEPTH %macro PREDICT_CHROMA_P 1 %if HIGH_BIT_DEPTH cglobal predict_8x%1c_p_core, 1,2,7 LOAD_PLANE_ARGS mova m3, [pw_pixel_max] pxor m1, m1 pmullw m2, [pw_43210123] ; b %if %1 == 16 pmullw m5, m4, [pw_m7] ; c %else pmullw m5, m4, [pw_m3] %endif paddw m5, [pw_16] %if mmsize == 32 mova xm6, xm4 paddw m4, m4 paddw m5, m6 %endif mov r1d, %1/(mmsize/16) .loop: paddsw m6, m2, m5 paddsw m6, m0 psraw m6, 5 CLIPW m6, m1, m3 paddw m5, m4 %if mmsize == 32 vextracti128 [r0], m6, 1 mova [r0+FDEC_STRIDEB], xm6 add r0, 2*FDEC_STRIDEB %else mova [r0], m6 add r0, FDEC_STRIDEB %endif dec r1d jg .loop RET %else ; !HIGH_BIT_DEPTH cglobal predict_8x%1c_p_core, 1,2 LOAD_PLANE_ARGS %if mmsize == 32 vbroadcasti128 m1, [pw_0to15] ; 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 pmullw m2, m1 mova xm1, xm4 ; zero upper half paddsw m4, m4 paddsw m0, m1 %else pmullw m2, [pw_0to15] %endif paddsw m0, m2 ; m0 = {i+0*b, i+1*b, i+2*b, i+3*b, i+4*b, i+5*b, i+6*b, i+7*b} paddsw m1, m0, m4 paddsw m4, m4 mov r1d, %1/(mmsize/8) .loop: psraw m2, m0, 5 psraw m3, m1, 5 paddsw m0, m4 paddsw m1, m4 packuswb m2, m3 %if mmsize == 32 movq [r0+FDEC_STRIDE*1], xm2 movhps [r0+FDEC_STRIDE*3], xm2 vextracti128 xm2, m2, 1 movq [r0+FDEC_STRIDE*0], xm2 movhps [r0+FDEC_STRIDE*2], xm2 %else movq [r0+FDEC_STRIDE*0], xm2 movhps [r0+FDEC_STRIDE*1], xm2 %endif add r0, FDEC_STRIDE*mmsize/8 dec r1d jg .loop RET %endif ; HIGH_BIT_DEPTH %endmacro ; PREDICT_CHROMA_P INIT_XMM sse2 PREDICT_CHROMA_P 8 PREDICT_CHROMA_P 16 INIT_XMM avx PREDICT_CHROMA_P 8 PREDICT_CHROMA_P 16 INIT_YMM avx2 PREDICT_CHROMA_P 8 PREDICT_CHROMA_P 16 ; ; void <API key>( uint8_t *src, int i00, int b, int c ) ; %if HIGH_BIT_DEPTH == 0 && ARCH_X86_64 == 0 INIT_MMX mmx2 cglobal <API key>, 1,2 LOAD_PLANE_ARGS movq mm5, mm2 movq mm1, mm2 pmullw mm5, [pw_0to15] psllw mm2, 3 psllw mm1, 2 movq mm3, mm2 paddsw mm0, mm5 ; mm0 = {i+ 0*b, i+ 1*b, i+ 2*b, i+ 3*b} paddsw mm1, mm0 ; mm1 = {i+ 4*b, i+ 5*b, i+ 6*b, i+ 7*b} paddsw mm2, mm0 ; mm2 = {i+ 8*b, i+ 9*b, i+10*b, i+11*b} paddsw mm3, mm1 ; mm3 = {i+12*b, i+13*b, i+14*b, i+15*b} mov r1d, 16 ALIGN 4 .loop: movq mm5, mm0 movq mm6, mm1 psraw mm5, 5 psraw mm6, 5 packuswb mm5, mm6 movq [r0], mm5 movq mm5, mm2 movq mm6, mm3 psraw mm5, 5 psraw mm6, 5 packuswb mm5, mm6 movq [r0+8], mm5 paddsw mm0, mm4 paddsw mm1, mm4 paddsw mm2, mm4 paddsw mm3, mm4 add r0, FDEC_STRIDE dec r1d jg .loop RET %endif ; !HIGH_BIT_DEPTH && !ARCH_X86_64 %macro PREDICT_16x16_P 0 cglobal <API key>, 1,2,8 movd m0, r1m movd m1, r2m movd m2, r3m SPLATW m0, m0, 0 SPLATW m1, m1, 0 SPLATW m2, m2, 0 pmullw m3, m1, [pw_0to15] psllw m1, 3 %if HIGH_BIT_DEPTH pxor m6, m6 mov r1d, 16 .loop: mova m4, m0 mova m5, m0 mova m7, m3 paddsw m7, m6 paddsw m4, m7 paddsw m7, m1 paddsw m5, m7 psraw m4, 5 psraw m5, 5 CLIPW m4, [pb_0], [pw_pixel_max] CLIPW m5, [pb_0], [pw_pixel_max] mova [r0], m4 mova [r0+16], m5 add r0, FDEC_STRIDEB paddw m6, m2 %else ; !HIGH_BIT_DEPTH paddsw m0, m3 ; m0 = {i+ 0*b, i+ 1*b, i+ 2*b, i+ 3*b, i+ 4*b, i+ 5*b, i+ 6*b, i+ 7*b} paddsw m1, m0 ; m1 = {i+ 8*b, i+ 9*b, i+10*b, i+11*b, i+12*b, i+13*b, i+14*b, i+15*b} paddsw m7, m2, m2 mov r1d, 8 ALIGN 4 .loop: psraw m3, m0, 5 psraw m4, m1, 5 paddsw m5, m0, m2 paddsw m6, m1, m2 psraw m5, 5 psraw m6, 5 packuswb m3, m4 packuswb m5, m6 mova [r0+FDEC_STRIDE*0], m3 mova [r0+FDEC_STRIDE*1], m5 paddsw m0, m7 paddsw m1, m7 add r0, FDEC_STRIDE*2 %endif ; !HIGH_BIT_DEPTH dec r1d jg .loop RET %endmacro ; PREDICT_16x16_P INIT_XMM sse2 PREDICT_16x16_P %if HIGH_BIT_DEPTH == 0 INIT_XMM avx PREDICT_16x16_P %endif INIT_YMM avx2 cglobal <API key>, 1,2,8*HIGH_BIT_DEPTH LOAD_PLANE_ARGS %if HIGH_BIT_DEPTH pmullw m2, [pw_0to15] pxor m5, m5 pxor m6, m6 mova m7, [pw_pixel_max] mov r1d, 8 .loop: paddsw m1, m2, m5 paddw m5, m4 paddsw m1, m0 paddsw m3, m2, m5 psraw m1, 5 paddsw m3, m0 psraw m3, 5 CLIPW m1, m6, m7 mova [r0+0*FDEC_STRIDEB], m1 CLIPW m3, m6, m7 mova [r0+1*FDEC_STRIDEB], m3 paddw m5, m4 add r0, 2*FDEC_STRIDEB %else ; !HIGH_BIT_DEPTH vbroadcasti128 m1, [pw_0to15] mova xm3, xm4 ; zero high bits pmullw m1, m2 psllw m2, 3 paddsw m0, m3 paddsw m0, m1 ; X+1*C X+0*C paddsw m1, m0, m2 ; Y+1*C Y+0*C paddsw m4, m4 mov r1d, 4 .loop: psraw m2, m0, 5 psraw m3, m1, 5 paddsw m0, m4 paddsw m1, m4 packuswb m2, m3 ; X+1*C Y+1*C X+0*C Y+0*C vextracti128 [r0+0*FDEC_STRIDE], m2, 1 mova [r0+1*FDEC_STRIDE], xm2 psraw m2, m0, 5 psraw m3, m1, 5 paddsw m0, m4 paddsw m1, m4 packuswb m2, m3 ; X+3*C Y+3*C X+2*C Y+2*C vextracti128 [r0+2*FDEC_STRIDE], m2, 1 mova [r0+3*FDEC_STRIDE], xm2 add r0, FDEC_STRIDE*4 %endif ; !HIGH_BIT_DEPTH dec r1d jg .loop RET %if HIGH_BIT_DEPTH == 0 %macro PREDICT_8x8 0 ; ; void predict_8x8_ddl( uint8_t *src, uint8_t *edge ) ; cglobal predict_8x8_ddl, 2,2 mova m0, [r1+16] %ifidn cpuname, ssse3 movd m2, [r1+32] palignr m2, m0, 1 %else movu m2, [r1+17] %endif pslldq m1, m0, 1 add r0, FDEC_STRIDE*4 PRED8x8_LOWPASS m0, m1, m2, m0, m3 %assign Y -4 %rep 8 psrldq m0, 1 movq [r0+Y*FDEC_STRIDE], m0 %assign Y (Y+1) %endrep RET %ifnidn cpuname, ssse3 ; ; void predict_8x8_ddr( uint8_t *src, uint8_t *edge ) ; cglobal predict_8x8_ddr, 2,2 movu m0, [r1+8] movu m1, [r1+7] psrldq m2, m0, 1 add r0, FDEC_STRIDE*4 PRED8x8_LOWPASS m0, m1, m2, m0, m3 psrldq m1, m0, 1 %assign Y 3 %rep 3 movq [r0+Y*FDEC_STRIDE], m0 movq [r0+(Y-1)*FDEC_STRIDE], m1 psrldq m0, 2 psrldq m1, 2 %assign Y (Y-2) %endrep movq [r0-3*FDEC_STRIDE], m0 movq [r0-4*FDEC_STRIDE], m1 RET ; ; void predict_8x8_vl( uint8_t *src, uint8_t *edge ) ; cglobal predict_8x8_vl, 2,2 mova m0, [r1+16] pslldq m1, m0, 1 psrldq m2, m0, 1 pavgb m3, m0, m2 add r0, FDEC_STRIDE*4 PRED8x8_LOWPASS m0, m1, m2, m0, m5 ; m0: (t0 + 2*t1 + t2 + 2) >> 2 ; m3: (t0 + t1 + 1) >> 1 %assign Y -4 %rep 3 psrldq m0, 1 movq [r0+ Y *FDEC_STRIDE], m3 movq [r0+(Y+1)*FDEC_STRIDE], m0 psrldq m3, 1 %assign Y (Y+2) %endrep psrldq m0, 1 movq [r0+ Y *FDEC_STRIDE], m3 movq [r0+(Y+1)*FDEC_STRIDE], m0 RET %endif ; !ssse3 ; ; void predict_8x8_vr( uint8_t *src, uint8_t *edge ) ; cglobal predict_8x8_vr, 2,2 movu m2, [r1+8] add r0, 4*FDEC_STRIDE pslldq m1, m2, 2 pslldq m0, m2, 1 pavgb m3, m2, m0 PRED8x8_LOWPASS m0, m2, m1, m0, m4 movhps [r0-4*FDEC_STRIDE], m3 movhps [r0-3*FDEC_STRIDE], m0 %if cpuflag(ssse3) punpckhqdq m3, m3 pshufb m0, [shuf_vr] palignr m3, m0, 13 %else mova m2, m0 mova m1, [pw_00ff] pand m1, m0 psrlw m0, 8 packuswb m1, m0 pslldq m1, 4 movhlps m3, m1 shufps m1, m2, q3210 psrldq m3, 5 psrldq m1, 5 SWAP 0, 1 %endif movq [r0+3*FDEC_STRIDE], m0 movq [r0+2*FDEC_STRIDE], m3 psrldq m0, 1 psrldq m3, 1 movq [r0+1*FDEC_STRIDE], m0 movq [r0+0*FDEC_STRIDE], m3 psrldq m0, 1 psrldq m3, 1 movq [r0-1*FDEC_STRIDE], m0 movq [r0-2*FDEC_STRIDE], m3 RET %endmacro ; PREDICT_8x8 INIT_XMM sse2 PREDICT_8x8 INIT_XMM ssse3 PREDICT_8x8 INIT_XMM avx PREDICT_8x8 %endif ; !HIGH_BIT_DEPTH ; ; void predict_8x8_vl( pixel *src, pixel *edge ) ; %macro PREDICT_8x8_VL_10 1 cglobal predict_8x8_vl, 2,2,8 mova m0, [r1+16*SIZEOF_PIXEL] mova m1, [r1+24*SIZEOF_PIXEL] PALIGNR m2, m1, m0, SIZEOF_PIXEL*1, m4 PSRLPIX m4, m1, 1 pavg%1 m6, m0, m2 pavg%1 m7, m1, m4 add r0, FDEC_STRIDEB*4 mova [r0-4*FDEC_STRIDEB], m6 PALIGNR m3, m7, m6, SIZEOF_PIXEL*1, m5 mova [r0-2*FDEC_STRIDEB], m3 PALIGNR m3, m7, m6, SIZEOF_PIXEL*2, m5 mova [r0+0*FDEC_STRIDEB], m3 PALIGNR m7, m7, m6, SIZEOF_PIXEL*3, m5 mova [r0+2*FDEC_STRIDEB], m7 PALIGNR m3, m1, m0, SIZEOF_PIXEL*7, m6 PSLLPIX m5, m0, 1 PRED8x8_LOWPASS m0, m5, m2, m0, m7 PRED8x8_LOWPASS m1, m3, m4, m1, m7 PALIGNR m4, m1, m0, SIZEOF_PIXEL*1, m2 mova [r0-3*FDEC_STRIDEB], m4 PALIGNR m4, m1, m0, SIZEOF_PIXEL*2, m2 mova [r0-1*FDEC_STRIDEB], m4 PALIGNR m4, m1, m0, SIZEOF_PIXEL*3, m2 mova [r0+1*FDEC_STRIDEB], m4 PALIGNR m1, m1, m0, SIZEOF_PIXEL*4, m2 mova [r0+3*FDEC_STRIDEB], m1 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_VL_10 w INIT_XMM ssse3 PREDICT_8x8_VL_10 w INIT_XMM avx PREDICT_8x8_VL_10 w %else INIT_MMX mmx2 PREDICT_8x8_VL_10 b %endif ; ; void predict_8x8_hd( pixel *src, pixel *edge ) ; %macro PREDICT_8x8_HD 2 cglobal predict_8x8_hd, 2,2 add r0, 4*FDEC_STRIDEB mova m0, [r1+ 8*SIZEOF_PIXEL] ; lt l0 l1 l2 l3 l4 l5 l6 movu m1, [r1+ 7*SIZEOF_PIXEL] ; l0 l1 l2 l3 l4 l5 l6 l7 %ifidn cpuname, ssse3 mova m2, [r1+16*SIZEOF_PIXEL] ; t7 t6 t5 t4 t3 t2 t1 t0 mova m4, m2 ; t7 t6 t5 t4 t3 t2 t1 t0 palignr m2, m0, 7*SIZEOF_PIXEL ; t6 t5 t4 t3 t2 t1 t0 lt palignr m4, m0, 1*SIZEOF_PIXEL ; t0 lt l0 l1 l2 l3 l4 l5 %else movu m2, [r1+15*SIZEOF_PIXEL] movu m4, [r1+ 9*SIZEOF_PIXEL] %endif ; cpuflag pavg%1 m3, m0, m1 PRED8x8_LOWPASS m0, m4, m1, m0, m5 PSRLPIX m4, m2, 2 ; .. .. t6 t5 t4 t3 t2 t1 PSRLPIX m1, m2, 1 ; .. t6 t5 t4 t3 t2 t1 t0 PRED8x8_LOWPASS m1, m4, m2, m1, m5 ; .. p11 p10 p9 punpckh%2 m2, m3, m0 ; p8 p7 p6 p5 punpckl%2 m3, m0 ; p4 p3 p2 p1 mova [r0+3*FDEC_STRIDEB], m3 PALIGNR m0, m2, m3, 2*SIZEOF_PIXEL, m5 mova [r0+2*FDEC_STRIDEB], m0 PALIGNR m0, m2, m3, 4*SIZEOF_PIXEL, m5 mova [r0+1*FDEC_STRIDEB], m0 PALIGNR m0, m2, m3, 6*SIZEOF_PIXEL, m3 mova [r0+0*FDEC_STRIDEB], m0 mova [r0-1*FDEC_STRIDEB], m2 PALIGNR m0, m1, m2, 2*SIZEOF_PIXEL, m5 mova [r0-2*FDEC_STRIDEB], m0 PALIGNR m0, m1, m2, 4*SIZEOF_PIXEL, m5 mova [r0-3*FDEC_STRIDEB], m0 PALIGNR m1, m1, m2, 6*SIZEOF_PIXEL, m2 mova [r0-4*FDEC_STRIDEB], m1 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_8x8_HD w, wd INIT_XMM ssse3 PREDICT_8x8_HD w, wd INIT_XMM avx PREDICT_8x8_HD w, wd %else INIT_MMX mmx2 PREDICT_8x8_HD b, bw ; ; void predict_8x8_hd( uint8_t *src, uint8_t *edge ) ; %macro PREDICT_8x8_HD 0 cglobal predict_8x8_hd, 2,2 add r0, 4*FDEC_STRIDE movu m1, [r1+7] movu m3, [r1+8] movu m2, [r1+9] pavgb m4, m1, m3 PRED8x8_LOWPASS m0, m1, m2, m3, m5 punpcklbw m4, m0 movhlps m0, m4 %assign Y 3 %rep 3 movq [r0+(Y)*FDEC_STRIDE], m4 movq [r0+(Y-4)*FDEC_STRIDE], m0 psrldq m4, 2 psrldq m0, 2 %assign Y (Y-1) %endrep movq [r0+(Y)*FDEC_STRIDE], m4 movq [r0+(Y-4)*FDEC_STRIDE], m0 RET %endmacro INIT_XMM sse2 PREDICT_8x8_HD INIT_XMM avx PREDICT_8x8_HD %endif ; HIGH_BIT_DEPTH %if HIGH_BIT_DEPTH == 0 ; ; void predict_8x8_hu( uint8_t *src, uint8_t *edge ) ; INIT_MMX cglobal predict_8x8_hu_sse2, 2,2 add r0, 4*FDEC_STRIDE movq mm1, [r1+7] ; l0 l1 l2 l3 l4 l5 l6 l7 pshufw mm0, mm1, q0123 ; l6 l7 l4 l5 l2 l3 l0 l1 movq mm2, mm0 psllw mm0, 8 psrlw mm2, 8 por mm2, mm0 ; l7 l6 l5 l4 l3 l2 l1 l0 psllq mm1, 56 ; l7 .. .. .. .. .. .. .. movq mm3, mm2 movq mm4, mm2 movq mm5, mm2 psrlq mm2, 8 psrlq mm3, 16 por mm2, mm1 ; l7 l7 l6 l5 l4 l3 l2 l1 punpckhbw mm1, mm1 por mm3, mm1 ; l7 l7 l7 l6 l5 l4 l3 l2 pavgb mm4, mm2 PRED8x8_LOWPASS mm1, mm3, mm5, mm2, mm6 movq2dq xmm0, mm4 movq2dq xmm1, mm1 punpcklbw xmm0, xmm1 punpckhbw mm4, mm1 %assign Y -4 %rep 3 movq [r0+Y*FDEC_STRIDE], xmm0 psrldq xmm0, 2 %assign Y (Y+1) %endrep pshufw mm5, mm4, q3321 pshufw mm6, mm4, q3332 pshufw mm7, mm4, q3333 movq [r0+Y*FDEC_STRIDE], xmm0 movq [r0+0*FDEC_STRIDE], mm4 movq [r0+1*FDEC_STRIDE], mm5 movq [r0+2*FDEC_STRIDE], mm6 movq [r0+3*FDEC_STRIDE], mm7 RET INIT_XMM cglobal <API key>, 2,2 add r0, 4*FDEC_STRIDE movq m3, [r1+7] pshufb m3, [shuf_hu] psrldq m1, m3, 1 psrldq m2, m3, 2 pavgb m0, m1, m3 PRED8x8_LOWPASS m1, m3, m2, m1, m4 punpcklbw m0, m1 %assign Y -4 %rep 3 movq [r0+ Y *FDEC_STRIDE], m0 movhps [r0+(Y+4)*FDEC_STRIDE], m0 psrldq m0, 2 pshufhw m0, m0, q2210 %assign Y (Y+1) %endrep movq [r0+ Y *FDEC_STRIDE], m0 movhps [r0+(Y+4)*FDEC_STRIDE], m0 RET %endif ; !HIGH_BIT_DEPTH ; ; void predict_8x8c_v( uint8_t *src ) ; %macro PREDICT_8x8C_V 0 cglobal predict_8x8c_v, 1,1 mova m0, [r0 - FDEC_STRIDEB] STORE8 m0 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse PREDICT_8x8C_V %else INIT_MMX mmx PREDICT_8x8C_V %endif %if HIGH_BIT_DEPTH INIT_MMX cglobal predict_8x8c_v_mmx, 1,1 mova m0, [r0 - FDEC_STRIDEB] mova m1, [r0 - FDEC_STRIDEB + 8] %assign Y 0 %rep 8 mova [r0 + (Y&1)*FDEC_STRIDEB], m0 mova [r0 + (Y&1)*FDEC_STRIDEB + 8], m1 %if (Y&1) && (Y!=7) add r0, FDEC_STRIDEB*2 %endif %assign Y Y+1 %endrep RET %endif %macro PREDICT_8x16C_V 0 cglobal predict_8x16c_v, 1,1 mova m0, [r0 - FDEC_STRIDEB] STORE16 m0 RET %endmacro %if HIGH_BIT_DEPTH INIT_XMM sse PREDICT_8x16C_V %else INIT_MMX mmx PREDICT_8x16C_V %endif ; ; void predict_8x8c_h( uint8_t *src ) ; %macro PREDICT_C_H 0 cglobal predict_8x8c_h, 1,1 %if cpuflag(ssse3) && notcpuflag(avx2) mova m2, [pb_3] %endif PRED_H_4ROWS 8, 1 PRED_H_4ROWS 8, 0 RET cglobal predict_8x16c_h, 1,2 %if cpuflag(ssse3) && notcpuflag(avx2) mova m2, [pb_3] %endif mov r1d, 4 .loop: PRED_H_4ROWS 8, 1 dec r1d jg .loop RET %endmacro INIT_MMX mmx2 PREDICT_C_H %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_C_H INIT_XMM avx2 PREDICT_C_H %else INIT_MMX ssse3 PREDICT_C_H %endif ; ; void predict_8x8c_dc( pixel *src ) ; %macro LOAD_LEFT 1 movzx r1d, pixel [r0+FDEC_STRIDEB*(%1-4)-SIZEOF_PIXEL] movzx r2d, pixel [r0+FDEC_STRIDEB*(%1-3)-SIZEOF_PIXEL] add r1d, r2d movzx r2d, pixel [r0+FDEC_STRIDEB*(%1-2)-SIZEOF_PIXEL] add r1d, r2d movzx r2d, pixel [r0+FDEC_STRIDEB*(%1-1)-SIZEOF_PIXEL] add r1d, r2d %endmacro %macro PREDICT_8x8C_DC 0 cglobal predict_8x8c_dc, 1,3 pxor m7, m7 %if HIGH_BIT_DEPTH movq m0, [r0-FDEC_STRIDEB+0] movq m1, [r0-FDEC_STRIDEB+8] HADDW m0, m2 HADDW m1, m2 %else ; !HIGH_BIT_DEPTH movd m0, [r0-FDEC_STRIDEB+0] movd m1, [r0-FDEC_STRIDEB+4] psadbw m0, m7 ; s0 psadbw m1, m7 ; s1 %endif add r0, FDEC_STRIDEB*4 LOAD_LEFT 0 ; s2 movd m2, r1d LOAD_LEFT 4 ; s3 movd m3, r1d punpcklwd m0, m1 punpcklwd m2, m3 punpckldq m0, m2 ; s0, s1, s2, s3 pshufw m3, m0, q3312 ; s2, s1, s3, s3 pshufw m0, m0, q1310 ; s0, s1, s3, s1 paddw m0, m3 psrlw m0, 2 pavgw m0, m7 ; s0+s2, s1, s3, s1+s3 %if HIGH_BIT_DEPTH %if cpuflag(sse2) movq2dq xmm0, m0 punpcklwd xmm0, xmm0 pshufd xmm1, xmm0, q3322 punpckldq xmm0, xmm0 %assign Y 0 %rep 8 %assign i (0 + (Y/4)) movdqa [r0+FDEC_STRIDEB*(Y-4)+0], xmm %+ i %assign Y Y+1 %endrep %else ; !sse2 pshufw m1, m0, q0000 pshufw m2, m0, q1111 pshufw m3, m0, q2222 pshufw m4, m0, q3333 %assign Y 0 %rep 8 %assign i (1 + (Y/4)*2) %assign j (2 + (Y/4)*2) movq [r0+FDEC_STRIDEB*(Y-4)+0], m %+ i movq [r0+FDEC_STRIDEB*(Y-4)+8], m %+ j %assign Y Y+1 %endrep %endif %else ; !HIGH_BIT_DEPTH packuswb m0, m0 punpcklbw m0, m0 movq m1, m0 punpcklbw m0, m0 punpckhbw m1, m1 %assign Y 0 %rep 8 %assign i (0 + (Y/4)) movq [r0+FDEC_STRIDEB*(Y-4)], m %+ i %assign Y Y+1 %endrep %endif RET %endmacro INIT_MMX mmx2 PREDICT_8x8C_DC %if HIGH_BIT_DEPTH INIT_MMX sse2 PREDICT_8x8C_DC %endif %if HIGH_BIT_DEPTH %macro STORE_4LINES 3 %if cpuflag(sse2) movdqa [r0+FDEC_STRIDEB*(%3-4)], %1 movdqa [r0+FDEC_STRIDEB*(%3-3)], %1 movdqa [r0+FDEC_STRIDEB*(%3-2)], %1 movdqa [r0+FDEC_STRIDEB*(%3-1)], %1 %else movq [r0+FDEC_STRIDEB*(%3-4)+0], %1 movq [r0+FDEC_STRIDEB*(%3-4)+8], %2 movq [r0+FDEC_STRIDEB*(%3-3)+0], %1 movq [r0+FDEC_STRIDEB*(%3-3)+8], %2 movq [r0+FDEC_STRIDEB*(%3-2)+0], %1 movq [r0+FDEC_STRIDEB*(%3-2)+8], %2 movq [r0+FDEC_STRIDEB*(%3-1)+0], %1 movq [r0+FDEC_STRIDEB*(%3-1)+8], %2 %endif %endmacro %else %macro STORE_4LINES 2 movq [r0+FDEC_STRIDEB*(%2-4)], %1 movq [r0+FDEC_STRIDEB*(%2-3)], %1 movq [r0+FDEC_STRIDEB*(%2-2)], %1 movq [r0+FDEC_STRIDEB*(%2-1)], %1 %endmacro %endif %macro PREDICT_8x16C_DC 0 cglobal predict_8x16c_dc, 1,3 pxor m7, m7 %if HIGH_BIT_DEPTH movq m0, [r0-FDEC_STRIDEB+0] movq m1, [r0-FDEC_STRIDEB+8] HADDW m0, m2 HADDW m1, m2 %else movd m0, [r0-FDEC_STRIDEB+0] movd m1, [r0-FDEC_STRIDEB+4] psadbw m0, m7 ; s0 psadbw m1, m7 ; s1 %endif punpcklwd m0, m1 ; s0, s1 add r0, FDEC_STRIDEB*4 LOAD_LEFT 0 ; s2 pinsrw m0, r1d, 2 LOAD_LEFT 4 ; s3 pinsrw m0, r1d, 3 ; s0, s1, s2, s3 add r0, FDEC_STRIDEB*8 LOAD_LEFT 0 ; s4 pinsrw m1, r1d, 2 LOAD_LEFT 4 ; s5 pinsrw m1, r1d, 3 ; s1, __, s4, s5 sub r0, FDEC_STRIDEB*8 pshufw m2, m0, q1310 ; s0, s1, s3, s1 pshufw m0, m0, q3312 ; s2, s1, s3, s3 pshufw m3, m1, q0302 ; s4, s1, s5, s1 pshufw m1, m1, q3322 ; s4, s4, s5, s5 paddw m0, m2 paddw m1, m3 psrlw m0, 2 psrlw m1, 2 pavgw m0, m7 pavgw m1, m7 %if HIGH_BIT_DEPTH %if cpuflag(sse2) movq2dq xmm0, m0 movq2dq xmm1, m1 punpcklwd xmm0, xmm0 punpcklwd xmm1, xmm1 pshufd xmm2, xmm0, q3322 pshufd xmm3, xmm1, q3322 punpckldq xmm0, xmm0 punpckldq xmm1, xmm1 STORE_4LINES xmm0, xmm0, 0 STORE_4LINES xmm2, xmm2, 4 STORE_4LINES xmm1, xmm1, 8 STORE_4LINES xmm3, xmm3, 12 %else pshufw m2, m0, q0000 pshufw m3, m0, q1111 pshufw m4, m0, q2222 pshufw m5, m0, q3333 STORE_4LINES m2, m3, 0 STORE_4LINES m4, m5, 4 pshufw m2, m1, q0000 pshufw m3, m1, q1111 pshufw m4, m1, q2222 pshufw m5, m1, q3333 STORE_4LINES m2, m3, 8 STORE_4LINES m4, m5, 12 %endif %else packuswb m0, m0 ; dc0, dc1, dc2, dc3 packuswb m1, m1 ; dc4, dc5, dc6, dc7 punpcklbw m0, m0 punpcklbw m1, m1 pshufw m2, m0, q1100 pshufw m3, m0, q3322 pshufw m4, m1, q1100 pshufw m5, m1, q3322 STORE_4LINES m2, 0 STORE_4LINES m3, 4 add r0, FDEC_STRIDEB*8 STORE_4LINES m4, 0 STORE_4LINES m5, 4 %endif RET %endmacro INIT_MMX mmx2 PREDICT_8x16C_DC %if HIGH_BIT_DEPTH INIT_MMX sse2 PREDICT_8x16C_DC %endif %macro PREDICT_C_DC_TOP 1 %if HIGH_BIT_DEPTH INIT_XMM cglobal predict_8x%1c_dc_top_sse2, 1,1 pxor m2, m2 mova m0, [r0 - FDEC_STRIDEB] pshufd m1, m0, q2301 paddw m0, m1 pshuflw m1, m0, q2301 pshufhw m1, m1, q2301 paddw m0, m1 psrlw m0, 1 pavgw m0, m2 STORE%1 m0 RET %else ; !HIGH_BIT_DEPTH INIT_MMX cglobal predict_8x%1c_dc_top_mmx2, 1,1 movq mm0, [r0 - FDEC_STRIDE] pxor mm1, mm1 pxor mm2, mm2 punpckhbw mm1, mm0 punpcklbw mm0, mm2 psadbw mm1, mm2 ; s1 psadbw mm0, mm2 ; s0 psrlw mm1, 1 psrlw mm0, 1 pavgw mm1, mm2 pavgw mm0, mm2 pshufw mm1, mm1, 0 pshufw mm0, mm0, 0 ; dc0 (w) packuswb mm0, mm1 ; dc0,dc1 (b) STORE%1 mm0 RET %endif %endmacro PREDICT_C_DC_TOP 8 PREDICT_C_DC_TOP 16 ; ; void predict_16x16_v( pixel *src ) ; %macro PREDICT_16x16_V 0 cglobal predict_16x16_v, 1,2 %assign %%i 0 %rep 16*SIZEOF_PIXEL/mmsize mova m %+ %%i, [r0-FDEC_STRIDEB+%%i*mmsize] %assign %%i %%i+1 %endrep %if 16*SIZEOF_PIXEL/mmsize == 4 STORE16 m0, m1, m2, m3 %elif 16*SIZEOF_PIXEL/mmsize == 2 STORE16 m0, m1 %else STORE16 m0 %endif RET %endmacro INIT_MMX mmx2 PREDICT_16x16_V INIT_XMM sse PREDICT_16x16_V %if HIGH_BIT_DEPTH INIT_YMM avx PREDICT_16x16_V %endif ; ; void predict_16x16_h( pixel *src ) ; %macro PREDICT_16x16_H 0 cglobal predict_16x16_h, 1,2 %if cpuflag(ssse3) && notcpuflag(avx2) mova m2, [pb_3] %endif mov r1d, 4 .loop: PRED_H_4ROWS 16, 1 dec r1d jg .loop RET %endmacro INIT_MMX mmx2 PREDICT_16x16_H %if HIGH_BIT_DEPTH INIT_XMM sse2 PREDICT_16x16_H INIT_YMM avx2 PREDICT_16x16_H %else ;no SSE2 for 8-bit, it's slower than MMX on all systems that don't support SSSE3 INIT_XMM ssse3 PREDICT_16x16_H %endif ; ; void <API key>( pixel *src, int i_dc_left ) ; %macro PRED16x16_DC_MMX 2 %if HIGH_BIT_DEPTH mova m0, [r0 - FDEC_STRIDEB+ 0] paddw m0, [r0 - FDEC_STRIDEB+ 8] paddw m0, [r0 - FDEC_STRIDEB+16] paddw m0, [r0 - FDEC_STRIDEB+24] HADDW m0, m1 paddw m0, %1 psrlw m0, %2 SPLATW m0, m0 STORE16 m0, m0, m0, m0 %else ; !HIGH_BIT_DEPTH pxor m0, m0 pxor m1, m1 psadbw m0, [r0 - FDEC_STRIDE] psadbw m1, [r0 - FDEC_STRIDE + 8] paddusw m0, m1 paddusw m0, %1 psrlw m0, %2 ; dc pshufw m0, m0, 0 packuswb m0, m0 ; dc in bytes STORE16 m0, m0 %endif %endmacro INIT_MMX mmx2 cglobal <API key>, 1,2 %if ARCH_X86_64 movd m6, r1d PRED16x16_DC_MMX m6, 5 %else PRED16x16_DC_MMX r1m, 5 %endif RET INIT_MMX mmx2 cglobal <API key>, 1,2 PRED16x16_DC_MMX [pw_8], 4 RET INIT_MMX mmx2 %if HIGH_BIT_DEPTH cglobal <API key>, 1,2 movd m0, r1m SPLATW m0, m0 STORE16 m0, m0, m0, m0 RET %else ; !HIGH_BIT_DEPTH cglobal <API key>, 1,1 movd m0, r1m pshufw m0, m0, 0 packuswb m0, m0 STORE16 m0, m0 RET %endif %macro PRED16x16_DC 2 %if HIGH_BIT_DEPTH mova xm0, [r0 - FDEC_STRIDEB+ 0] paddw xm0, [r0 - FDEC_STRIDEB+16] HADDW xm0, xm2 paddw xm0, %1 psrlw xm0, %2 SPLATW m0, xm0 %if mmsize == 32 STORE16 m0 %else STORE16 m0, m0 %endif %else ; !HIGH_BIT_DEPTH pxor m0, m0 psadbw m0, [r0 - FDEC_STRIDE] MOVHL m1, m0 paddw m0, m1 paddusw m0, %1 psrlw m0, %2 ; dc SPLATW m0, m0 packuswb m0, m0 ; dc in bytes STORE16 m0 %endif %endmacro %macro <API key> 0 cglobal <API key>, 2,2,4 movd xm3, r1m PRED16x16_DC xm3, 5 RET cglobal <API key>, 1,2 PRED16x16_DC [pw_8], 4 RET cglobal <API key>, 1,2 movd xm0, r1m SPLATW m0, xm0 %if HIGH_BIT_DEPTH && mmsize == 16 STORE16 m0, m0 %else %if HIGH_BIT_DEPTH == 0 packuswb m0, m0 %endif STORE16 m0 %endif RET %endmacro INIT_XMM sse2 <API key> %if HIGH_BIT_DEPTH INIT_YMM avx2 <API key> %else INIT_XMM avx2 <API key> %endif
<! <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>WebGL texture texSubImage2Ds cube map conformance test.</title> <link rel="stylesheet" href="../../../resources/js-test-style.css"/> <script src="../../../js/js-test-pre.js"></script> <script src="../../../js/webgl-test-utils.js"></script> </head> <body> <canvas id="example" width="256" height="256" style="width: 40px; height: 40px;"></canvas> <div id="description"></div> <div id="console"></div> <script id="vshader" type="x-shader/x-vertex"> attribute vec4 vPosition; uniform mat4 rotation; varying vec3 texCoord; void main() { gl_Position = vPosition; vec4 direction = vec4(vPosition.x * 0.5, vPosition.y * 0.5, 1, 1); texCoord = normalize((rotation * direction).xyz); } </script> <script id="fshader" type="x-shader/x-fragment"> precision mediump float; uniform samplerCube tex; varying vec3 texCoord; void main() { gl_FragColor = textureCube(tex, normalize(texCoord)); } </script> <script> "use strict"; var canvas; description("Checks issues with size of cube map textures"); debug(""); var wtu = WebGLTestUtils; var canvas = document.getElementById("example"); var gl = wtu.create3DContext(canvas); wtu.setupUnitQuad(gl, 0, 1); var program = wtu.setupProgram( gl, ['vshader', 'fshader'], ['vPosition', 'texCoord0'], [0, 1]); var rotLoc = gl.getUniformLocation(program, "rotation"); var size = 16; var colors = [ {name: 'red', color: [255, 0, 0, 255]}, {name: 'green', color: [ 0, 255, 0, 255]}, {name: 'blue', color: [ 0, 0, 255, 255]}, {name: 'yellow', color: [255, 255, 0, 255]}, {name: 'cyan', color: [ 0, 255, 255, 255]}, {name: 'magenta', color: [255, 0, 255, 255]} ]; var targets = [ gl.<API key>, gl.<API key>, gl.<API key>, gl.<API key>, gl.<API key>, gl.<API key>]; var rotations = [ {axis: [0, 1, 0], angle: Math.PI / 2}, {axis: [0, 1, 0], angle: -Math.PI / 2}, {axis: [1, 0, 0], angle: -Math.PI / 2}, {axis: [1, 0, 0], angle: Math.PI / 2}, {axis: [0, 1, 0], angle: 0}, {axis: [0, 1, 0], angle: Math.PI}, ]; var halfRotations = [ {colors: [3, 4], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4}]}, {colors: [4, 2], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4}]}, {colors: [5, 3], rotations: [{axis: [1, 0, 0], angle: Math.PI / 4 * 3}]}, {colors: [2, 5], rotations: [{axis: [1, 0, 0], angle: -Math.PI / 4 * 3}]}, {colors: [3, 0], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2}, {axis: [1, 0, 0], angle: Math.PI / 4}]}, {colors: [0, 2], rotations: [{axis: [0, 1, 0], angle: Math.PI / 2}, {axis: [1, 0, 0], angle: -Math.PI / 4}]}, ]; var count = 0; testSize(size); function testSize(size) { debug(""); debug("testing size: " + size); var canvasSize = Math.max(size / 4, 2); canvas.width = canvasSize; canvas.height = canvasSize; gl.viewport(0, 0, canvasSize, canvasSize); var tex = gl.createTexture(); gl.bindTexture(gl.TEXTURE_CUBE_MAP, tex); // Seems like I should be using LINEAR here with some other math // to make sure I get more mip coverage but that's easier said // than done. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.NEAREST); for (var jj = 0; jj < 2; ++jj) { for (var tt = 0; tt < targets.length; ++tt) { var color = colors[(tt + count) % colors.length]; fillLevel(targets[tt], 0, size, color.color); } if (jj == 1) { debug("use mipmap"); gl.texParameteri( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.<API key>); gl.generateMipmap(gl.TEXTURE_CUBE_MAP); } var err = gl.getError(); if (err == gl.OUT_OF_MEMORY) { debug("out of memory"); return false; } if (err != gl.NO_ERROR) { testFailed("unexpected gl error: " + wtu.glEnumToString(gl, err)); } for (var rr = 0; rr < rotations.length; ++rr) { var rot = rotations[rr]; var color = colors[(rr + count) % colors.length]; var rotMat = axisRotation(rot.axis, rot.angle); gl.uniformMatrix4fv(rotLoc, false, rotMat); wtu.<API key>(gl); wtu.checkCanvas( gl, color.color, wtu.glEnumToString(gl, targets[rr]) + " should be " + color.name); } for (var rr = 0; rr < halfRotations.length; ++rr) { var h = halfRotations[rr]; var rots = h.rotations; var rotMat = axisRotation(rots[0].axis, rots[0].angle); for (var ii = 1; ii < rots.length; ++ii) { var tmpMat = axisRotation(rots[ii].axis, rots[ii].angle); var rotMat = mulMatrix(tmpMat, rotMat); } gl.uniformMatrix4fv(rotLoc, false, rotMat); wtu.<API key>(gl); for (var ii = 0; ii < 2; ++ii) { checkRect( 0, canvasSize / 2 * ii, canvasSize, canvasSize / 2, colors[(h.colors[ii] + count) % colors.length]); } } ++count; } gl.deleteTexture(tex); return true; } wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors."); function checkRect(x, y, width, height, color) { wtu.checkCanvasRect( gl, x, y, width, height, color.color, "" + x + ", " + y + ", " + width + ", " + height + " should be " + color.name); } function fillLevel(target, level, size, color) { var numPixels = size * size; var halfPixelRow = new Uint8Array(size * 2); for (var jj = 0; jj < size; ++jj) { var off = jj * 4; halfPixelRow[off + 0] = color[0]; halfPixelRow[off + 1] = color[1]; halfPixelRow[off + 2] = color[2]; halfPixelRow[off + 3] = color[3]; } gl.texImage2D( target, level, gl.RGBA, size, size, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); for (var jj = 0; jj < size; ++jj) { gl.texSubImage2D( target, level, 0, jj, size / 2, 1, gl.RGBA, gl.UNSIGNED_BYTE, halfPixelRow); gl.texSubImage2D( target, level, size / 2, jj, size / 2, 1, gl.RGBA, gl.UNSIGNED_BYTE, halfPixelRow); } } function printMat(mat) { debug("" + mat[0] + ", " + mat[1] + ", " + mat[2] + ", " + mat[3] + ", "); debug("" + mat[4] + ", " + mat[5] + ", " + mat[6] + ", " + mat[7] + ", "); debug("" + mat[8] + ", " + mat[9] + ", " + mat[10] + ", " + mat[11] + ", "); debug("" + mat[12] + ", " + mat[13] + ", " + mat[14] + ", " + mat[15] + ", "); } function axisRotation(axis, angle) { var dst = new Float32Array(16); var x = axis[0]; var y = axis[1]; var z = axis[2]; var n = Math.sqrt(x * x + y * y + z * z); x /= n; y /= n; z /= n; var xx = x * x; var yy = y * y; var zz = z * z; var c = Math.cos(angle); var s = Math.sin(angle); var oneMinusCosine = 1 - c; dst[ 0] = xx + (1 - xx) * c; dst[ 1] = x * y * oneMinusCosine + z * s; dst[ 2] = x * z * oneMinusCosine - y * s; dst[ 3] = 0; dst[ 4] = x * y * oneMinusCosine - z * s; dst[ 5] = yy + (1 - yy) * c; dst[ 6] = y * z * oneMinusCosine + x * s; dst[ 7] = 0; dst[ 8] = x * z * oneMinusCosine + y * s; dst[ 9] = y * z * oneMinusCosine - x * s; dst[10] = zz + (1 - zz) * c; dst[11] = 0; dst[12] = 0; dst[13] = 0; dst[14] = 0; dst[15] = 1; return dst; }; function mulMatrix(a, b) { var dst = new Float32Array(16); var a00 = a[0]; var a01 = a[1]; var a02 = a[2]; var a03 = a[3]; var a10 = a[ 4 + 0]; var a11 = a[ 4 + 1]; var a12 = a[ 4 + 2]; var a13 = a[ 4 + 3]; var a20 = a[ 8 + 0]; var a21 = a[ 8 + 1]; var a22 = a[ 8 + 2]; var a23 = a[ 8 + 3]; var a30 = a[12 + 0]; var a31 = a[12 + 1]; var a32 = a[12 + 2]; var a33 = a[12 + 3]; var b00 = b[0]; var b01 = b[1]; var b02 = b[2]; var b03 = b[3]; var b10 = b[ 4 + 0]; var b11 = b[ 4 + 1]; var b12 = b[ 4 + 2]; var b13 = b[ 4 + 3]; var b20 = b[ 8 + 0]; var b21 = b[ 8 + 1]; var b22 = b[ 8 + 2]; var b23 = b[ 8 + 3]; var b30 = b[12 + 0]; var b31 = b[12 + 1]; var b32 = b[12 + 2]; var b33 = b[12 + 3]; dst[ 0] = a00 * b00 + a01 * b10 + a02 * b20 + a03 * b30; dst[ 1] = a00 * b01 + a01 * b11 + a02 * b21 + a03 * b31; dst[ 2] = a00 * b02 + a01 * b12 + a02 * b22 + a03 * b32; dst[ 3] = a00 * b03 + a01 * b13 + a02 * b23 + a03 * b33; dst[ 4] = a10 * b00 + a11 * b10 + a12 * b20 + a13 * b30; dst[ 5] = a10 * b01 + a11 * b11 + a12 * b21 + a13 * b31; dst[ 6] = a10 * b02 + a11 * b12 + a12 * b22 + a13 * b32; dst[ 7] = a10 * b03 + a11 * b13 + a12 * b23 + a13 * b33; dst[ 8] = a20 * b00 + a21 * b10 + a22 * b20 + a23 * b30; dst[ 9] = a20 * b01 + a21 * b11 + a22 * b21 + a23 * b31; dst[10] = a20 * b02 + a21 * b12 + a22 * b22 + a23 * b32; dst[11] = a20 * b03 + a21 * b13 + a22 * b23 + a23 * b33; dst[12] = a30 * b00 + a31 * b10 + a32 * b20 + a33 * b30; dst[13] = a30 * b01 + a31 * b11 + a32 * b21 + a33 * b31; dst[14] = a30 * b02 + a31 * b12 + a32 * b22 + a33 * b32; dst[15] = a30 * b03 + a31 * b13 + a32 * b23 + a33 * b33; return dst; }; var successfullyParsed = true; </script> <script src="../../../js/js-test-post.js"></script> </body> </html>
(function(factory) { if (typeof module === 'object' && module.exports) { module.exports = factory; } else { factory(Highcharts); } }(function(Highcharts) { (function(H) { 'use strict'; var win = H.win, doc = win.document, noop = function() {}, Color = H.Color, Series = H.Series, seriesTypes = H.seriesTypes, each = H.each, extend = H.extend, addEvent = H.addEvent, fireEvent = H.fireEvent, grep = H.grep, isNumber = H.isNumber, merge = H.merge, pick = H.pick, wrap = H.wrap, plotOptions = H.getOptions().plotOptions, CHUNK_SIZE = 50000, destroyLoadingDiv; function eachAsync(arr, fn, finalFunc, chunkSize, i) { i = i || 0; chunkSize = chunkSize || CHUNK_SIZE; var threshold = i + chunkSize, proceed = true; while (proceed && i < threshold && i < arr.length) { proceed = fn(arr[i], i); i = i + 1; } if (proceed) { if (i < arr.length) { setTimeout(function() { eachAsync(arr, fn, finalFunc, chunkSize, i); }); } else if (finalFunc) { finalFunc(); } } } // Set default options each(['area', 'arearange', 'column', 'line', 'scatter'], function(type) { if (plotOptions[type]) { plotOptions[type].boostThreshold = 5000; } }); /** * Override a bunch of methods the same way. If the number of points is below the threshold, * run the original method. If not, check for a canvas version or do nothing. */ each(['translate', 'generatePoints', 'drawTracker', 'drawPoints', 'render'], function(method) { function branch(proceed) { var letItPass = this.options.stacking && (method === 'translate' || method === 'generatePoints'); if ((this.processedXData || this.options.data).length < (this.options.boostThreshold || Number.MAX_VALUE) || letItPass) { // Clear image if (method === 'render' && this.image) { this.image.attr({ href: '' }); this.animate = null; // We're zooming in, don't run animation } proceed.call(this); // If a canvas version of the method exists, like renderCanvas(), run } else if (this[method + 'Canvas']) { this[method + 'Canvas'](); } } wrap(Series.prototype, method, branch); // A special case for some types - its translate method is already wrapped if (method === 'translate') { if (seriesTypes.column) { wrap(seriesTypes.column.prototype, method, branch); } if (seriesTypes.arearange) { wrap(seriesTypes.arearange.prototype, method, branch); } } }); /** * Do not compute extremes when min and max are set. * If we use this in the core, we can add the hook to hasExtremes to the methods directly. */ wrap(Series.prototype, 'getExtremes', function(proceed) { if (!this.hasExtremes()) { proceed.apply(this, Array.prototype.slice.call(arguments, 1)); } }); wrap(Series.prototype, 'setData', function(proceed) { if (!this.hasExtremes(true)) { proceed.apply(this, Array.prototype.slice.call(arguments, 1)); } }); wrap(Series.prototype, 'processData', function(proceed) { if (!this.hasExtremes(true)) { proceed.apply(this, Array.prototype.slice.call(arguments, 1)); } }); H.extend(Series.prototype, { pointRange: 0, allowDG: false, // No data grouping, let boost handle large data hasExtremes: function(checkX) { var options = this.options, data = options.data, xAxis = this.xAxis && this.xAxis.options, yAxis = this.yAxis && this.yAxis.options; return data.length > (options.boostThreshold || Number.MAX_VALUE) && isNumber(yAxis.min) && isNumber(yAxis.max) && (!checkX || (isNumber(xAxis.min) && isNumber(xAxis.max))); }, /** * If implemented in the core, parts of this can probably be shared with other similar * methods in Highcharts. */ destroyGraphics: function() { var series = this, points = this.points, point, i; if (points) { for (i = 0; i < points.length; i = i + 1) { point = points[i]; if (point && point.graphic) { point.graphic = point.graphic.destroy(); } } } each(['graph', 'area', 'tracker'], function(prop) { if (series[prop]) { series[prop] = series[prop].destroy(); } }); }, /** * Create a hidden canvas to draw the graph on. The contents is later copied over * to an SVG image element. */ getContext: function() { var chart = this.chart, width = chart.plotWidth, height = chart.plotHeight, ctx = this.ctx, swapXY = function(proceed, x, y, a, b, c, d) { proceed.call(this, y, x, a, b, c, d); }; if (!this.canvas) { this.canvas = doc.createElement('canvas'); this.image = chart.renderer.image('', 0, 0, width, height).add(this.group); this.ctx = ctx = this.canvas.getContext('2d'); if (chart.inverted) { each(['moveTo', 'lineTo', 'rect', 'arc'], function(fn) { wrap(ctx, fn, swapXY); }); } } else { ctx.clearRect(0, 0, width, height); } this.canvas.width = width; this.canvas.height = height; this.image.attr({ width: width, height: height }); return ctx; }, /** * Draw the canvas image inside an SVG image */ canvasToSVG: function() { this.image.attr({ href: this.canvas.toDataURL('image/png') }); }, cvsLineTo: function(ctx, clientX, plotY) { ctx.lineTo(clientX, plotY); }, renderCanvas: function() { var series = this, options = series.options, chart = series.chart, xAxis = this.xAxis, yAxis = this.yAxis, ctx, c = 0, xData = series.processedXData, yData = series.processedYData, rawData = options.data, xExtremes = xAxis.getExtremes(), xMin = xExtremes.min, xMax = xExtremes.max, yExtremes = yAxis.getExtremes(), yMin = yExtremes.min, yMax = yExtremes.max, pointTaken = {}, lastClientX, sampling = !!series.sampling, points, r = options.marker && options.marker.radius, cvsDrawPoint = this.cvsDrawPoint, cvsLineTo = options.lineWidth ? this.cvsLineTo : false, cvsMarker = r <= 1 ? this.cvsMarkerSquare : this.cvsMarkerCircle, enableMouseTracking = options.enableMouseTracking !== false, lastPoint, threshold = options.threshold, yBottom = yAxis.getThreshold(threshold), hasThreshold = isNumber(threshold), translatedThreshold = yBottom, doFill = this.fill, isRange = series.pointArrayMap && series.pointArrayMap.join(',') === 'low,high', isStacked = !!options.stacking, cropStart = series.cropStart || 0, loadingOptions = chart.options.loading, requireSorting = series.requireSorting, wasNull, connectNulls = options.connectNulls, useRaw = !xData, minVal, maxVal, minI, maxI, fillColor = series.fillOpacity ? new Color(series.color).setOpacity(pick(options.fillOpacity, 0.75)).get() : series.color, stroke = function() { if (doFill) { ctx.fillStyle = fillColor; ctx.fill(); } else { ctx.strokeStyle = series.color; ctx.lineWidth = options.lineWidth; ctx.stroke(); } }, drawPoint = function(clientX, plotY, yBottom) { if (c === 0) { ctx.beginPath(); if (cvsLineTo) { ctx.lineJoin = 'round'; } } if (wasNull) { ctx.moveTo(clientX, plotY); } else { if (cvsDrawPoint) { cvsDrawPoint(ctx, clientX, plotY, yBottom, lastPoint); } else if (cvsLineTo) { cvsLineTo(ctx, clientX, plotY); } else if (cvsMarker) { cvsMarker(ctx, clientX, plotY, r); } } // We need to stroke the line for every 1000 pixels. It will crash the browser // memory use if we stroke too infrequently. c = c + 1; if (c === 1000) { stroke(); c = 0; } // Area charts need to keep track of the last point lastPoint = { clientX: clientX, plotY: plotY, yBottom: yBottom }; }, addKDPoint = function(clientX, plotY, i) { // The k-d tree requires series points. Reduce the amount of points, since the time to build the // tree increases exponentially. if (enableMouseTracking && !pointTaken[clientX + ',' + plotY]) { pointTaken[clientX + ',' + plotY] = true; if (chart.inverted) { clientX = xAxis.len - clientX; plotY = yAxis.len - plotY; } points.push({ clientX: clientX, plotX: clientX, plotY: plotY, i: cropStart + i }); } }; // If we are zooming out from SVG mode, destroy the graphics if (this.points || this.graph) { this.destroyGraphics(); } // The group series.plotGroup( 'group', 'series', series.visible ? 'visible' : 'hidden', options.zIndex, chart.seriesGroup ); series.markerGroup = series.group; addEvent(series, 'destroy', function() { series.markerGroup = null; }); points = this.points = []; ctx = this.getContext(); series.buildKDTree = noop; // Do not start building while drawing // Display a loading indicator if (rawData.length > 99999) { chart.options.loading = merge(loadingOptions, { labelStyle: { backgroundColor: H.color('#ffffff').setOpacity(0.75).get(), padding: '1em', borderRadius: '0.5em' }, style: { backgroundColor: 'none', opacity: 1 } }); clearTimeout(destroyLoadingDiv); chart.showLoading('Drawing...'); chart.options.loading = loadingOptions; // reset } // Loop over the points eachAsync(isStacked ? series.data : (xData || rawData), function(d, i) { var x, y, clientX, plotY, isNull, low, chartDestroyed = typeof chart.index === 'undefined', isYInside = true; if (!chartDestroyed) { if (useRaw) { x = d[0]; y = d[1]; } else { x = d; y = yData[i]; } // Resolve low and high for range series if (isRange) { if (useRaw) { y = d.slice(1, 3); } low = y[0]; y = y[1]; } else if (isStacked) { x = d.x; y = d.stackY; low = y - d.y; } isNull = y === null; // Optimize for scatter zooming if (!requireSorting) { isYInside = y >= yMin && y <= yMax; } if (!isNull && x >= xMin && x <= xMax && isYInside) { clientX = Math.round(xAxis.toPixels(x, true)); if (sampling) { if (minI === undefined || clientX === lastClientX) { if (!isRange) { low = y; } if (maxI === undefined || y > maxVal) { maxVal = y; maxI = i; } if (minI === undefined || low < minVal) { minVal = low; minI = i; } } if (clientX !== lastClientX) { // Add points and reset if (minI !== undefined) { // then maxI is also a number plotY = yAxis.toPixels(maxVal, true); yBottom = yAxis.toPixels(minVal, true); drawPoint( clientX, hasThreshold ? Math.min(plotY, translatedThreshold) : plotY, hasThreshold ? Math.max(yBottom, translatedThreshold) : yBottom ); addKDPoint(clientX, plotY, maxI); if (yBottom !== plotY) { addKDPoint(clientX, yBottom, minI); } } minI = maxI = undefined; lastClientX = clientX; } } else { plotY = Math.round(yAxis.toPixels(y, true)); drawPoint(clientX, plotY, yBottom); addKDPoint(clientX, plotY, i); } } wasNull = isNull && !connectNulls; if (i % CHUNK_SIZE === 0) { series.canvasToSVG(); } } return !chartDestroyed; }, function() { var loadingDiv = chart.loadingDiv, loadingShown = chart.loadingShown; stroke(); series.canvasToSVG(); fireEvent(series, 'renderedCanvas'); // Do not use chart.hideLoading, as it runs JS animation and will be blocked by buildKDTree. // CSS animation looks good, but then it must be deleted in timeout. If we add the module to core, // change hideLoading so we can skip this block. if (loadingShown) { extend(loadingDiv.style, { transition: 'opacity 250ms', opacity: 0 }); chart.loadingShown = false; destroyLoadingDiv = setTimeout(function() { if (loadingDiv.parentNode) { // In exporting it is falsy loadingDiv.parentNode.removeChild(loadingDiv); } chart.loadingDiv = chart.loadingSpan = null; }, 250); } // Pass tests in Pointer. // Replace this with a single property, and replace when zooming in // below boostThreshold. series.directTouch = false; series.options.stickyTracking = true; delete series.buildKDTree; // Go back to prototype, ready to build series.buildKDTree(); // Don't do async on export, the exportChart, getSVGForExport and getSVG methods are not chained for it. }, chart.renderer.forExport ? Number.MAX_VALUE : undefined); } }); seriesTypes.scatter.prototype.cvsMarkerCircle = function(ctx, clientX, plotY, r) { ctx.moveTo(clientX, plotY); ctx.arc(clientX, plotY, r, 0, 2 * Math.PI, false); }; // Rect is twice as fast as arc, should be used for small markers seriesTypes.scatter.prototype.cvsMarkerSquare = function(ctx, clientX, plotY, r) { ctx.rect(clientX - r, plotY - r, r * 2, r * 2); }; seriesTypes.scatter.prototype.fill = true; extend(seriesTypes.area.prototype, { cvsDrawPoint: function(ctx, clientX, plotY, yBottom, lastPoint) { if (lastPoint && clientX !== lastPoint.clientX) { ctx.moveTo(lastPoint.clientX, lastPoint.yBottom); ctx.lineTo(lastPoint.clientX, lastPoint.plotY); ctx.lineTo(clientX, plotY); ctx.lineTo(clientX, yBottom); } }, fill: true, fillOpacity: true, sampling: true }); extend(seriesTypes.column.prototype, { cvsDrawPoint: function(ctx, clientX, plotY, yBottom) { ctx.rect(clientX - 1, plotY, 1, yBottom - plotY); }, fill: true, sampling: true }); Series.prototype.getPoint = function(boostPoint) { var point = boostPoint; if (boostPoint && !(boostPoint instanceof this.pointClass)) { point = (new this.pointClass()).init(this, this.options.data[boostPoint.i]); // eslint-disable-line new-cap point.category = point.x; point.dist = boostPoint.dist; point.distX = boostPoint.distX; point.plotX = boostPoint.plotX; point.plotY = boostPoint.plotY; } return point; }; /** * Extend series.destroy to also remove the fake k-d-tree points (#5137). Normally * this is handled by Series.destroy that calls Point.destroy, but the fake * search points are not registered like that. */ wrap(Series.prototype, 'destroy', function(proceed) { var series = this, chart = series.chart; if (chart.hoverPoints) { chart.hoverPoints = grep(chart.hoverPoints, function(point) { return point.series === series; }); } if (chart.hoverPoint && chart.hoverPoint.series === series) { chart.hoverPoint = null; } proceed.call(this); }); /** * Return a point instance from the k-d-tree */ wrap(Series.prototype, 'searchPoint', function(proceed) { return this.getPoint( proceed.apply(this, [].slice.call(arguments, 1)) ); }); }(Highcharts)); }));
# Lazy-loading feature modules By default, NgModules are eagerly loaded, which means that as soon as the application loads, so do all the NgModules, whether or not they are immediately necessary. For large applications with lots of routes, consider lazy loading&mdash;a design pattern that loads NgModules as needed. Lazy loading helps keep initial bundle sizes smaller, which in turn helps decrease load times. <div class="alert is-helpful"> For the final sample application with two lazy-loaded modules that this page describes, see the <live-example></live-example>. </div> {@a lazy-loading} ## Lazy loading basics This section introduces the basic procedure for configuring a lazy-loaded route. For a step-by-step example, see the [step-by-step setup](#step-by-step) section on this page. To lazy load Angular modules, use `loadChildren` (instead of `component`) in your `AppRoutingModule` `routes` configuration as follows. <code-example header="AppRoutingModule (excerpt)"> const routes: Routes = [ { path: 'items', loadChildren: () => import('./items/items.module').then(m => m.ItemsModule) } ]; </code-example> In the lazy-loaded module's routing module, add a route for the component. <code-example header="Routing module for lazy loaded module (excerpt)"> const routes: Routes = [ { path: '', component: ItemsComponent } ]; </code-example> Also be sure to remove the `ItemsModule` from the `AppModule`. For step-by-step instructions on lazy loading modules, continue with the following sections of this page. {@a step-by-step} ## Step-by-step setup There are two main steps to setting up a lazy-loaded feature module: 1. Create the feature module with the CLI, using the `--route` flag. 1. Configure the routes. Set up an app If you don’t already have an app, follow the following steps to create one with the CLI. If you already have an app, skip to [Configure the routes](#config-routes). Enter the following command where `customer-app` is the name of your app: <code-example language="bash"> ng new customer-app --routing </code-example> This creates an application called `customer-app` and the `--routing` flag generates a file called `app-routing.module.ts`, which is one of the files you need for setting up lazy loading for your feature module. Navigate into the project by issuing the command `cd customer-app`. <div class="alert is-helpful"> The `--routing` option requires Angular/CLI version 8.1 or higher. See [Keeping Up to Date](guide/updating). </div> Create a feature module with routing Next, you’ll need a feature module with a component to route to. To make one, enter the following command in the terminal, where `customers` is the name of the feature module. The path for loading the `customers` feature modules is also `customers` because it is specified with the `--route` option: <code-example language="bash"> ng generate module customers --route customers --module app.module </code-example> This creates a `customers` folder having the new lazy-loadable feature module `CustomersModule` defined in the `customers.module.ts` file and the routing module `<API key>` defined in the `customers-routing.module.ts` file. The command automatically declares the `CustomersComponent` and imports `<API key>` inside the new feature module. Because the new module is meant to be lazy-loaded, the command does NOT add a reference to the new feature module in the application's root module file, `app.module.ts`. Instead, it adds the declared route, `customers` to the `routes` array declared in the module provided as the `--module` option. <code-example header="src/app/app-routing.module.ts" path="<API key>/src/app/app-routing.module.ts" region="routes-customers"> </code-example> Notice that the lazy-loading syntax uses `loadChildren` followed by a function that uses the browser's built-in `import('...')` syntax for dynamic imports. The import path is the relative path to the module. <div class="callout is-helpful"> <header>String-based lazy loading</header> In Angular version 8, the string syntax for the `loadChildren` route specification [was deprecated](guide/deprecations#<API key>) in favor of the `import()` syntax. However, you can opt into using string-based lazy loading (`loadChildren: './path/to/module#Module'`) by including the lazy-loaded routes in your `tsconfig` file, which includes the lazy-loaded files in the compilation. By default the CLI generates projects with stricter file inclusions intended to be used with the `import()` syntax. </div> Add another feature module Use the same command to create a second lazy-loaded feature module with routing, along with its stub component. <code-example language="bash"> ng generate module orders --route orders --module app.module </code-example> This creates a new folder called `orders` containing the `OrdersModule` and `OrdersRoutingModule`, along with the new `OrdersComponent` source files. The `orders` route, specified with the `--route` option, is added to the `routes` array inside the `app-routing.module.ts` file, using the lazy-loading syntax. <code-example header="src/app/app-routing.module.ts" path="<API key>/src/app/app-routing.module.ts" region="<API key>"> </code-example> Set up the UI Though you can type the URL into the address bar, a navigation UI is straightforward for the user and more common. Replace the default placeholder markup in `app.component.html` with a custom nav so you can navigate to your modules in the browser: <code-example path="<API key>/src/app/app.component.html" header="app.component.html" region="<API key>" header="src/app/app.component.html"></code-example> To see your application in the browser so far, enter the following command in the terminal window: <code-example language="bash"> ng serve </code-example> Then go to `localhost:4200` where you should see “customer-app” and three buttons. <div class="lightbox"> <img src="generated/images/guide/<API key>/three-buttons.png" width="300" alt="three buttons in the browser"> </div> These buttons work, because the CLI automatically added the routes to the feature modules to the `routes` array in `app-routing.module.ts`. {@a config-routes} Imports and route configuration The CLI automatically added each feature module to the routes map at the application level. Finish this off by adding the default route. In the `app-routing.module.ts` file, update the `routes` array with the following: <code-example path="<API key>/src/app/app-routing.module.ts" id="app-routing.module.ts" region="const-routes" header="src/app/app-routing.module.ts"></code-example> The first two paths are the routes to the `CustomersModule` and the `OrdersModule`. The final entry defines a default route. The empty path matches everything that doesn't match an earlier path. Inside the feature module Next, take a look at the `customers.module.ts` file. If you’re using the CLI and following the steps outlined in this page, you don’t have to do anything here. <code-example path="<API key>/src/app/customers/customers.module.ts" id="customers.module.ts" region="customers-module" header="src/app/customers/customers.module.ts"></code-example> The `customers.module.ts` file imports the `customers-routing.module.ts` and `customers.component.ts` files. `<API key>` is listed in the `@NgModule` `imports` array giving `CustomersModule` access to its own routing module. `CustomersComponent` is in the `declarations` array, which means `CustomersComponent` belongs to the `CustomersModule`. The `app-routing.module.ts` then imports the feature module, `customers.module.ts` using JavaScript's dynamic import. The feature-specific route definition file `customers-routing.module.ts` imports its own feature component defined in the `customers.component.ts` file, along with the other JavaScript import statements. It then maps the empty path to the `CustomersComponent`. <code-example path="<API key>/src/app/customers/customers-routing.module.ts" id="customers-routing.module.ts" region="<API key>" header="src/app/customers/customers-routing.module.ts"></code-example> The `path` here is set to an empty string because the path in `AppRoutingModule` is already set to `customers`, so this route in the `<API key>`, is already within the `customers` context. Every route in this routing module is a child route. The other feature module's routing module is configured similarly. <code-example path="<API key>/src/app/orders/orders-routing.module.ts" id="orders-routing.module.ts" region="<API key>" header="src/app/orders/orders-routing.module.ts (excerpt)"></code-example> Verify lazy loading You can check to see that a module is indeed being lazy loaded with the Chrome developer tools. In Chrome, open the developer tools by pressing `Cmd+Option+i` on a Mac or `Ctrl+Shift+j` on a PC and go to the Network Tab. <div class="lightbox"> <img src="generated/images/guide/<API key>/network-tab.png" width="600" alt="lazy loaded modules diagram"> </div> Click on the Orders or Customers button. If you see a chunk appear, everything is wired up properly and the feature module is being lazy loaded. A chunk should appear for Orders and for Customers but only appears once for each. <div class="lightbox"> <img src="generated/images/guide/<API key>/chunk-arrow.png" width="600" alt="lazy loaded modules diagram"> </div> To see it again, or to test after working in the project, clear everything out by clicking the circle with a line through it in the upper left of the Network Tab: <div class="lightbox"> <img src="generated/images/guide/<API key>/clear.gif" width="200" alt="lazy loaded modules diagram"> </div> Then reload with `Cmd+r` or `Ctrl+r`, depending on your platform. ## `forRoot()` and `forChild()` You might have noticed that the CLI adds `RouterModule.forRoot(routes)` to the `AppRoutingModule` `imports` array. This lets Angular know that the `AppRoutingModule` is a routing module and `forRoot()` specifies that this is the root routing module. It configures all the routes you pass to it, gives you access to the router directives, and registers the `Router` service. Use `forRoot()` only once in the application, inside the `AppRoutingModule`. The CLI also adds `RouterModule.forChild(routes)` to feature routing modules. This way, Angular knows that the route list is only responsible for providing additional routes and is intended for feature modules. You can use `forChild()` in multiple modules. The `forRoot()` method takes care of the *global* injector configuration for the Router. The `forChild()` method has no injector configuration. It uses directives such as `RouterOutlet` and `RouterLink`. For more information, see the [`forRoot()` pattern](guide/singleton-services#forRoot) section of the [Singleton Services](guide/singleton-services) guide. {@a preloading} ## Preloading Preloading improves UX by loading parts of your application in the background. You can preload modules or component data. Preloading modules Preloading modules improves UX by loading parts of your application in the background so users don't have to wait for the elements to download when they activate a route. To enable preloading of all lazy loaded modules, import the `PreloadAllModules` token from the Angular `router`. <code-example header="AppRoutingModule (excerpt)"> import { PreloadAllModules } from '@angular/router'; </code-example> Still in the `AppRoutingModule`, specify your preloading strategy in `forRoot()`. <code-example header="AppRoutingModule (excerpt)"> RouterModule.forRoot( appRoutes, { preloadingStrategy: PreloadAllModules } ) </code-example> Preloading component data To preload component data, use a `resolver`. Resolvers improve UX by blocking the page load until all necessary data is available to fully display the page. # Resolvers Create a resolver service. With the CLI, the command to generate a service is as follows: <code-example language="sh"> ng generate service <service-name> </code-example> In the newly-created service, implement the `Resolve` interface provided by the `@angular/router` package: <code-example header="Resolver service (excerpt)"> import { Resolve } from '@angular/router'; /* An interface that represents your data model */ export interface Crisis { id: number; name: string; } export class <API key> implements Resolve<Crisis> { resolve(route: <API key>, state: RouterStateSnapshot): Observable<Crisis> { // your logic goes here } } </code-example> Import this resolver into your module's routing module. <code-example header="Feature module's routing module (excerpt)"> import { <API key> } from './<API key>.service'; </code-example> Add a `resolve` object to the component's `route` configuration. <code-example header="Feature module's routing module (excerpt)"> { path: '/your-path', component: YourComponent, resolve: { crisis: <API key> } } </code-example> In the component's constructor, inject an instance of the `ActivatedRoute` class that represents the current route. <code-example header="Component's constructor (excerpt)"> import { ActivatedRoute } from '@angular/router'; @Component({ ... }) class YourComponent { constructor(private route: ActivatedRoute) {} } </code-example> Use the injected instance of the `ActivatedRoute` class to access `data` associated with a given route. <code-example header="Component's ngOnInit lifecycle hook (excerpt)"> import { ActivatedRoute } from '@angular/router'; @Component({ ... }) class YourComponent { constructor(private route: ActivatedRoute) {} ngOnInit() { this.route.data .subscribe(data => { const crisis: Crisis = data.crisis; }); } } </code-example> For more information with a working example, see the [routing tutorial section on preloading](guide/router-tutorial-toh#<API key>). ## Troubleshooting lazy-loading modules A common error when lazy-loading modules is importing common modules in multiple places within an application. Test for this condition by first generating the module using the Angular CLI and including the `--route route-name` parameter, where `route-name` is the name of your module. Next, generate the module without the `--route` parameter. If the Angular CLI generates an error when you use the `--route` parameter, but runs correctly without it, you might have imported the same module in multiple places. Remember, many common Angular modules should be imported at the base of your application. For more information on Angular Modules, see [NgModules](guide/ngmodules). ## More on NgModules and routing You might also be interested in the following: * [Routing and Navigation](guide/router). * [Providers](guide/providers). * [Types of Feature Modules](guide/module-types). * [Route-level code-splitting in Angular](https://web.dev/<API key>/) * [Route preloading strategies in Angular](https://web.dev/<API key>/)
define("d3/test/geo/<API key>", ["dojo","dijit","dojox"], function(dojo,dijit,dojox){ var vows = require("vows"), load = require("../load"), assert = require("../assert"), projectionTestSuite = require("./<API key>"); var suite = vows.describe("d3.geo.azimuthalEqualArea"); suite.addBatch({ "azimuthalEqualArea": { topic: load("geo/<API key>").expression("d3.geo.azimuthalEqualArea"), "default": projectionTestSuite({ topic: function(projection) { return projection(); } }, { "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 470.78325089, 51.18095336]], "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 448.09318291, 57.65281089]], "Svalbard": [[ 3.13977663, 61.55241523], [ 484.55622556, 96.45697185]], "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 428.30355841, 405.56446813]], "Tokyo": [[ 33.38709832, 79.49539834], [ 499.82677711, 55.68926131]], "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 452.67706228]], "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 47.32293772]] }), "translated to 0,0 and at scale 1": projectionTestSuite({ topic: function(projection) { return projection().translate([0, 0]).scale(1); } }, { "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.06144499, -1.32546031]], "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.21271211, -1.28231459]], "Svalbard": [[ 3.13977663, 61.55241523], [ 0.03037484, -1.02362019]], "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.34464294, 1.03709645]], "Tokyo": [[ 33.38709832, 79.49539834], [ 0.13217851, -1.29540492]], "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.35118042]], "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.35118042]] }) } }); suite.export(module); });
var Adapter, adapter, store, serializer, Person; module("Record Attribute Transforms", { setup: function() { Adapter = DS.Adapter.extend(); Adapter.registerTransform('unobtainium', { serialize: function(value) { return 'serialize'; }, deserialize: function(value) { return 'fromData'; } }); adapter = Adapter.create(); store = DS.Store.create({ adapter: adapter }); serializer = adapter.get('serializer'); }, teardown: function() { serializer.destroy(); adapter.destroy(); store.destroy(); } }); test("transformed values should be materialized on the record", function() { var Person = DS.Model.extend({ name: DS.attr('unobtainium') }); store.load(Person, { id: 1, name: "James Cameron" }); var person = store.find(Person, 1); equal(person.get('name'), 'fromData', "value of attribute on the record should be transformed"); var json = adapter.serialize(person); equal(json.name, "serialize", "value of attribute in the JSON hash should be transformed"); }); module("Default DS.Transforms", { setup: function() { store = DS.Store.create(); Person = DS.Model.extend({ name: DS.attr('string'), born: DS.attr('date'), age: DS.attr('number'), isGood: DS.attr('boolean') }); }, teardown: function() { store.destroy(); } }); test("the default numeric transform", function() { store.load(Person, {id: 1, age: "51"}); var person = store.find(Person, 1); var result = (typeof person.get('age') === "number"); equal(result, true, "string is transformed into a number"); equal(person.get('age'),51, "string value and transformed numeric value match"); }); test("the default boolean transform", function() { store.load(Person, {id: 1, isGood: "false"}); store.load(Person, {id: 2, isGood: "f"}); store.load(Person, {id: 3, isGood: 0}); store.load(Person, {id: 4, isGood: false}); var personOne = store.find(Person, 1); var personTwo = store.find(Person, 2); var personThree = store.find(Person, 3); var personFour = store.find(Person, 4); var result = (typeof personOne.get('isGood') === "boolean"); equal(result, true, "string is transformed into a boolean"); equal(personOne.get('isGood'), false, "string value and transformed boolean value match"); equal(personTwo.get('isGood'), false, "short string value and transformed boolean value match"); equal(personThree.get('isGood'), false, "numeric value and transformed boolean value match"); equal(personFour.get('isGood'), false, "boolean value and transformed boolean value match"); }); test("the default string transform", function() { store.load(Person, {id: 1, name: 8675309}); var person = store.find(Person, 1); var result = (typeof person.get('name') === "string"); equal(result, true, "number is transformed into a string"); equal(person.get('name'), "8675309", "numeric value and transformed string value match"); }); test("the default date transform", function() { var date = new Date(); store.load(Person, {id: 1, born: date.toString()}); var person = store.find(Person, 1); var result = (person.get('born') instanceof Date); equal(result, true, "string is transformed into a date"); equal(person.get('born').toString(), date.toString(), "date.toString and transformed date.toString values match"); var timestamp = 293810400, // 1979-04-24 @ 08:00:00 date2 = new Date(timestamp); store.load(Person, {id: 2, born: timestamp}); var person2 = store.find(Person, 2); var result2 = (person.get('born') instanceof Date); equal(result2, true, "timestamp is transformed into a date"); equal(person2.get('born').toString(), date2.toString(), "date.toString and transformed date.toString values match"); }); test("the date transform parses iso8601 dates", function() { var expectDate = function(string, timestamp, message) { equal(Ember.Date.parse(string), timestamp, message); }; expectDate('2011-11-29T15:52:18.867', 1322581938867, "YYYY-MM-DDTHH:mm:ss.sss"); expectDate('2011-11-29T15:52:18.867Z', 1322581938867, "YYYY-MM-DDTHH:mm:ss.sssZ"); expectDate('2011-11-29T15:52:18.867-03:30', 1322594538867, "YYYY-MM-DDTHH:mm:ss.sss-HH:mm"); expectDate('2011-11-29', 1322524800000, "YYYY-MM-DD"); expectDate('2011-11', 1320105600000, "YYYY-MM"); expectDate('2011', 1293840000000, "YYYY"); }); module("Enum Transforms", { setup: function() { Adapter = DS.Adapter.extend(); Adapter.<API key>('materials', ['unobtainium', 'kindaobtainium', 'veryobtainium']); adapter = Adapter.create(); store = DS.Store.create({ adapter: adapter }); serializer = adapter.get('serializer'); Person = DS.Model.extend({ material: DS.attr('materials') }); }, teardown: function() { serializer.destroy(); adapter.destroy(); store.destroy(); } }); test("correct transforms are applied", function() { var json, person; store.load(Person, { id: 1, material: 2 }); person = store.find(Person, 1); equal(person.get('material'), 'veryobtainium', 'value of the attribute on the record should be transformed'); json = adapter.serialize(person); equal(json.material, 2, 'value of the attribute in the JSON hash should be transformed'); });
#ifdef __MICROBLAZE__ #warning "The driver is supported only for ARM architecture" #else #include <xil_types.h> #include <xpseudo_asm.h> #ifdef __ICCARM__ #define INLINE #else #define INLINE __inline #endif /* DCC Status Bits */ #define <API key> (1 << 30) #define <API key> (1 << 29) static INLINE u32 <API key>(void); void <API key>(u32 BaseAddress, u8 Data) { (void) BaseAddress; while (<API key>() & <API key>) dsb(); #ifdef __aarch64__ asm volatile ("msr dbgdtrtx_el0, %0" : : "r" (Data)); #elif defined (__GNUC__) || defined (__ICCARM__) asm volatile("mcr p14, 0, %0, c0, c5, 0" : : "r" (Data)); #else { volatile register u32 Reg __asm("cp14:0:c0:c5:0"); Reg = Data; } #endif isb(); } u8 <API key>(u32 BaseAddress) { u8 Data = 0U; (void) BaseAddress; while (!(<API key>() & <API key>)) dsb(); #ifdef __aarch64__ asm volatile ("mrs %0, dbgdtrrx_el0" : "=r" (Data)); #elif defined (__GNUC__) || defined (__ICCARM__) asm volatile("mrc p14, 0, %0, c0, c5, 0" : "=r" (Data)); #else { volatile register u32 Reg __asm("cp14:0:c0:c5:0"); Data = Reg; } #endif isb(); return Data; } static INLINE u32 <API key>(void) { u32 Status = 0U; #ifdef __aarch64__ asm volatile ("mrs %0, mdccsr_el0" : "=r" (Status)); #elif defined (__GNUC__) || defined (__ICCARM__) asm volatile("mrc p14, 0, %0, c0, c1, 0" : "=r" (Status) : : "cc"); #else { volatile register u32 Reg __asm("cp14:0:c0:c1:0"); Status = Reg; } #endif return Status; #endif }
streamaApp.controller('adminMovieCtrl', [ '$scope', 'apiService', '$stateParams', 'modalService', '$state', 'uploadService', function ($scope, apiService, $stateParams, modalService, $state, uploadService) { apiService.movie.get($stateParams.movieId).success(function (data) { $scope.movie = data; }); $scope.delete = function(){ alertify.confirm("Are you sure, you want to delete this Movie?", function (confirmed) { if(confirmed){ apiService.movie.delete($stateParams.movieId).success(function () { $state.go('admin.movies'); }); } }) }; $scope.uploadStatus = {}; $scope.upload = uploadService.doUpload.bind(uploadService, $scope.uploadStatus, 'video/uploadFile.json?id=' + $stateParams.movieId, function (data) { $scope.uploadStatus.percentage = null; $scope.movie.files = $scope.movie.files || []; $scope.movie.files.push(data); }); }]);
package org.spongycastle.util.encoders.test; import java.io.IOException; import org.spongycastle.util.Strings; import org.spongycastle.util.encoders.DecoderException; import org.spongycastle.util.encoders.Hex; import org.spongycastle.util.encoders.HexEncoder; public class HexTest extends AbstractCoderTest { private static final String invalid1 = "%O4T"; private static final String invalid2 = "FZI4"; private static final String invalid3 = "ae%E"; private static final String invalid4 = "fO4%"; private static final String invalid5 = "beefe"; private static final String invalid6 = "beefs"; public HexTest( String name) { super(name); } protected void setUp() { super.setUp(); enc = new HexEncoder(); } protected char paddingChar() { return 0; } protected boolean isEncodedChar(char c) { if ('A' <= c && c <= 'F') { return true; } if ('a' <= c && c <= 'f') { return true; } if ('0' <= c && c <= '9') { return true; } return false; } public void testInvalidInput() throws IOException { String[] invalid = new String[] { invalid1, invalid2, invalid3, invalid4, invalid5, invalid6 }; for (int i = 0; i != invalid.length; i++) { invalidTest(invalid[i]); invalidTest(Strings.toByteArray(invalid[i])); } } private void invalidTest(String data) { try { Hex.decode(data); } catch (DecoderException e) { return; } fail("invalid String data parsed"); } private void invalidTest(byte[] data) { try { Hex.decode(data); } catch (DecoderException e) { return; } fail("invalid byte data parsed"); } }
(function() { // global closure var page = require('webpage').create(), // imports fs = require('fs'), system = require('system'), // arguments baseExamplesUrl = system.args[1], exampleDir = system.args[2], // various settings ignoreFiles = [ 'index.html' ], intervalMillisecs = 25, renderMillisecs = 2000, // basic variables curDir = fs.workingDirectory, exampleDirList = fs.list(exampleDir), pageindex = 0, fileName = '', htmlFiles = [], lenHtmlFiles = 0, loadInProgress = false; // simple object with helper functions var util = { /** * Returns the basename of a file given a path. */ baseName: function(path) { var parts = path.split(fs.separator); return parts[parts.length - 1]; }, /** * Super basic test whether a file can be considered a HTML-file. */ isHtmlFile: function(filename) { return (/\.html?$/).test(filename); }, /** * Appends a slash to given string if it isn't there already. */ appendSlash: function(str) { return ((/\/$/).test(str)) ? str : str + '/'; }, /** * Generates an URL out of given baseurl and path. */ buildUrl: function(baseurl, path) { var name = util.baseName(path), mode = 'raw'; return util.appendSlash(baseurl) + name + '?mode=' + mode; }, /** * Simple progressbar logger that uses our globals pageindex & lenHtmlFiles. */ logProgress: function() { var doneSymbol = '-', todoSymbol = ' ', currentSymbol = '>', barStrLeft = '[', barStrRight = ']', progresStep = 5, // one doneSymbol equals this percentage totalSteps = Math.round(100 / progresStep), ratio = (lenHtmlFiles === 0) ? 0 : (pageindex / lenHtmlFiles), percent = (ratio === 0) ? 0 : ratio * 100, normalizedNumDone = Math.floor(ratio * totalSteps), normalizedNumTodo = totalSteps - normalizedNumDone, progressLine = '', i = 0; // the progress bar progressLine += barStrLeft; for (; i < normalizedNumDone; i++) { progressLine += doneSymbol; } for (i = 0; i < normalizedNumTodo; i++) { progressLine += (i === 0) ? currentSymbol : todoSymbol; } progressLine += barStrRight; // the percentage information // pad if necessary if (percent < 10) { progressLine += ' '; } else if (percent < 100) { progressLine += ' '; } progressLine += ' ' + percent.toFixed(1) + ' % done'; // additional information if (fileName !== '') { progressLine += ', ' + util.baseName(fileName) + ''; } console.log(progressLine); } }; // iterate over all files in examples directory // and find the HTML files. for (var i = 0; i < exampleDirList.length; i++) { var fullpath = exampleDir + fs.separator + exampleDirList[i]; if (fs.isFile(fullpath) && util.isHtmlFile(fullpath) && ignoreFiles.indexOf(util.baseName(fullpath)) === -1) { //TODO: make this more async (i.e. pop on/off stack WHILE rending pages) htmlFiles.push(fullpath); } } lenHtmlFiles = htmlFiles.length; console.log('Capturing ' + lenHtmlFiles + ' example screenshots.'); // The main interval function that is executed regularly and renders a // page to a file var interval = setInterval(function() { if (!loadInProgress && pageindex < lenHtmlFiles) { util.logProgress(); fileName = htmlFiles[pageindex]; page.viewportSize = { width: 800, height: 600 }; page.clipRect = { top: 0, left: 0, width: page.viewportSize.width, height: page.viewportSize.height }; page.open(util.buildUrl(baseExamplesUrl, htmlFiles[pageindex])); } if (pageindex == lenHtmlFiles) { util.logProgress(); console.log(lenHtmlFiles + ' screenshots captured.'); phantom.exit(); } }, intervalMillisecs); // set loadInProgress flag so we only process one image at time. page.onLoadStarted = function() { loadInProgress = true; }; // When the page is loaded, render it to an image page.onLoadFinished = function() { var dest = exampleDir + fs.separator + util.baseName(fileName) + '.png'; window.setTimeout(function() { loadInProgress = false; page.render(dest); // actually render the page. pageindex++; }, renderMillisecs); }; })(); // eof global closure
using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Windows.Forms; using DotSpatial.Controls.Docking; namespace DotSpatial.Examples.<API key>.<API key> { <summary> Simple implmenentation of IDockManager. It shows a technique how to create own dock manager as extension. You may delete this class in your application. In this case default dock manager control will be used. </summary> internal class MdiDocking : IDockManager, <API key> { #region Fields [Import("Shell")] private ContainerControl Shell { get; set; } private readonly List<Form> _forms = new List<Form>(); #endregion #region IDockManager Members <summary> Occurs when the active panel is changed, meaning a difference panel is activated. </summary> public event EventHandler<<API key>> ActivePanelChanged; <summary> Occurs when a panel is closed, which means the panel can still be activated or removed. </summary> public event EventHandler<<API key>> PanelClosed; <summary> Occurs after a panel is added. </summary> public event EventHandler<<API key>> PanelAdded; <summary> Occurs after a panel is removed. </summary> public event EventHandler<<API key>> PanelRemoved; <summary> Occurs when a panel is hidden. </summary> public event EventHandler<<API key>> PanelHidden; <summary> Removes the specified panel. </summary> <param name="key">The key.</param> public void Remove(string key) { var form = GetFormByKey(key); if (form != null) { form.Close(); _forms.Remove(form); form.Activated -= form_Activated; form.VisibleChanged -= <API key>; form.Closed -= FormOnClosed; OnPanelRemoved(new <API key>(key)); } } <summary> Selects the panel. </summary> <param name="key">The key.</param> public void SelectPanel(string key) { var form = GetFormByKey(key); if (form != null) form.Focus(); } <summary> Adds the specified panel. </summary> <param name="panel"></param> public void Add(DockablePanel panel) { Add(panel.Key, panel.Caption, panel.InnerControl, panel.Dock); OnPanelAdded(new <API key>(panel.Key)); } public void ResetLayout() { _forms.ForEach(_ => _.Show(Shell)); } #endregion protected virtual void OnPanelRemoved(<API key> ea) { if (PanelRemoved != null) PanelRemoved(this, ea); } protected virtual void OnPanelAdded(<API key> ea) { if (PanelAdded != null) PanelAdded(this, ea); } protected virtual void OnPanelClosed(<API key> ea) { if (PanelClosed != null) PanelClosed(this, ea); } protected virtual void <API key>(<API key> ea) { if (ActivePanelChanged != null) ActivePanelChanged(this, ea); } protected virtual void OnPanelHidden(<API key> ea) { if (PanelHidden != null) PanelHidden(this, ea); } public void Add(string key, string caption, Control panel, DockStyle dockStyle) { if (panel == null) throw new <API key>("panel"); panel.Dock = DockStyle.Fill; var form = new Form { Name = key, Text = panel.Text, Width = panel.Width, Height = panel.Height, MdiParent = Shell as Form, }; form.Controls.Add(panel); form.Activated += form_Activated; form.VisibleChanged += <API key>; form.Closed += FormOnClosed; _forms.Add(form); form.Show(); } private void FormOnClosed(object sender, EventArgs eventArgs) { OnPanelClosed(new <API key>(((Form)sender).Name)); } private void <API key>(object sender, EventArgs eventArgs) { var form = (Form) sender; if (!form.Visible) { OnPanelHidden(new <API key>(form.Name)); } } private void form_Activated(object sender, EventArgs e) { <API key>(new <API key>(((Form)sender).Name)); } public void HidePanel(string key) { var form = GetFormByKey(key); if (form != null) { form.Hide(); } } public void ShowPanel(string key) { var form = GetFormByKey(key); if (form != null) { form.Show(); } } private Form GetFormByKey(string key) { return _forms.FirstOrDefault(_ => _.Name == key); } public void OnImportsSatisfied() { var form = Shell as Form; if (form != null) form.IsMdiContainer = true; } } }
// detail/array.hpp #ifndef <API key> #define <API key> #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #if defined(ASIO_HAS_STD_ARRAY) # include <array> #else // defined(ASIO_HAS_STD_ARRAY) # include <boost/array.hpp> #endif // defined(ASIO_HAS_STD_ARRAY) namespace asio { namespace detail { #if defined(ASIO_HAS_STD_ARRAY) using std::array; #else // defined(ASIO_HAS_STD_ARRAY) using boost::array; #endif // defined(ASIO_HAS_STD_ARRAY) } // namespace detail } // namespace asio #endif // <API key>
/* rasterizer_gles3.h */ /* This file is part of: */ /* GODOT ENGINE */ /* 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, */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* included in all copies or substantial portions of the Software. */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* 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 RASTERIZERGLES3_H #define RASTERIZERGLES3_H #include "<API key>.h" #include "<API key>.h" #include "<API key>.h" #include "servers/visual/rasterizer.h" class RasterizerGLES3 : public Rasterizer { static Rasterizer *_create_current(); <API key> *storage; <API key> *canvas; <API key> *scene; uint64_t prev_ticks; double time_total; public: virtual RasterizerStorage *get_storage(); virtual RasterizerCanvas *get_canvas(); virtual RasterizerScene *get_scene(); virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale); virtual void initialize(); virtual void begin_frame(); virtual void <API key>(RID p_render_target); virtual void <API key>(); virtual void clear_render_target(const Color &p_color); virtual void <API key>(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0); virtual void end_frame(); virtual void finalize(); static void make_current(); static void register_config(); RasterizerGLES3(); ~RasterizerGLES3(); }; #endif // RASTERIZERGLES3_H
<!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - <API key> / getCheckedNodes</TITLE> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../css/demo.css" type="text/css"> <link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css"> <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script> <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script> <! <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script> <SCRIPT type="text/javascript"> <! var setting = { view: { selectedMulti: false }, check: { enable: true }, data: { simpleData: { enable: true } }, callback: { onCheck: onCheck } }; var zNodes =[ { id:1, pId:0, name:" 1", open:true}, { id:11, pId:1, name:" 1-1"}, { id:12, pId:1, name:" 1-2", open:true}, { id:121, pId:12, name:" 1-2-1", checked:true}, { id:122, pId:12, name:" 1-2-2"}, { id:123, pId:12, name:" 1-2-3"}, { id:13, pId:1, name:" 1-3"}, { id:2, pId:0, name:" 2", open:true}, { id:21, pId:2, name:" 2-1"}, { id:22, pId:2, name:" 2-2", open:true}, { id:221, pId:22, name:" 2-2-1", checked:true}, { id:222, pId:22, name:" 2-2-2"}, { id:223, pId:22, name:" 2-2-3"}, { id:23, pId:2, name:" 2-3", checked:true} ]; var clearFlag = false; function onCheck(e, treeId, treeNode) { count(); if (clearFlag) { <API key>(); } } function <API key>() { var zTree = $.fn.zTree.getZTreeObj("treeDemo"), nodes = zTree.<API key>(); for (var i=0, l=nodes.length; i<l; i++) { nodes[i].checkedOld = nodes[i].checked; } } function count() { var zTree = $.fn.zTree.getZTreeObj("treeDemo"), checkCount = zTree.getCheckedNodes(true).length, nocheckCount = zTree.getCheckedNodes(false).length, changeCount = zTree.<API key>().length; $("#checkCount").text(checkCount); $("#nocheckCount").text(nocheckCount); $("#changeCount").text(changeCount); } function createTree() { $.fn.zTree.init($("#treeDemo"), setting, zNodes); count(); clearFlag = $("#last").attr("checked"); } $(document).ready(function(){ createTree(); $("#init").bind("change", createTree); $("#last").bind("change", createTree); }); </SCRIPT> </HEAD> <BODY> <h1>checkbox </h1> <h6>[ : excheck/checkbox_count.html ]</h6> <div class="content_wrap"> <div class="zTreeDemoBackground left"> <ul id="treeDemo" class="ztree"></ul> </div> <div class="right"> <ul class="info"> <li class="title"><h2>1<API key> / getCheckedNodes </h2> <ul class="list"> <li class="highlight_red"> zTreeObj.<API key> / getCheckedNodes API </li> <li><p> checkbox <br/> <ul id="log" class="log" style="height:110px;"> <li> <span id="checkCount" class="highlight_red"></span> </li> <li> <span id="nocheckCount" class="highlight_red"></span> </li> <li><input type="radio" id="init" name="stateType" class="radio first" checked /><span> zTree </span><br/> <input type="radio" id="last" name="stateType" class="radio first" style="margin-left:108px;"/><span></span></li> <li> <span id="changeCount" class="highlight_red"></span> </li> </ul></p> </li> </ul> </li> <li class="title"><h2>2setting </h2> <ul class="list"> <li> "checkbox " </li> </ul> </li> <li class="title"><h2>3treeNode </h2> <ul class="list"> <li> "checkbox " </li> </ul> </li> </ul> </div> </div> </BODY> </HTML>
Ext.onReady(function(){ Ext.QuickTips.init(); var xg = Ext.grid; // shared reader var reader = new Ext.data.ArrayReader({}, [ {name: 'company'}, {name: 'price', type: 'float'}, {name: 'change', type: 'float'}, {name: 'pctChange', type: 'float'}, {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}, {name: 'industry'}, {name: 'desc'} ]); var store = new Ext.data.GroupingStore({ reader: reader, data: xg.dummyData, sortInfo:{field: 'company', direction: "ASC"}, groupField:'industry' }); var grid = new xg.GridPanel({ store: store, columns: [ {id:'company',header: "Company", width: 60, sortable: true, dataIndex: 'company'}, {header: "Price", width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'}, {header: "Change", width: 20, sortable: true, dataIndex: 'change', renderer: Ext.util.Format.usMoney}, {header: "Industry", width: 20, sortable: true, dataIndex: 'industry'}, {header: "Last Updated", width: 20, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'} ], view: new Ext.grid.GroupingView({ forceFit:true, groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' }), frame:true, width: 700, height: 450, collapsible: true, animCollapse: false, title: 'Grouping Example', iconCls: 'icon-grid', fbar : ['->', { text:'Clear Grouping', iconCls: 'icon-clear-group', handler : function(){ store.clearGrouping(); } }], renderTo: document.body }); }); // Array data for the grids Ext.grid.dummyData = [ ['3m Co',71.72,0.02,0.03,'4/2 12:00am', 'Manufacturing'], ['Alcoa Inc',29.01,0.42,1.47,'4/1 12:00am', 'Manufacturing'], ['Altria Group Inc',83.81,0.28,0.34,'4/3 12:00am', 'Manufacturing'], ['American Express Company',52.55,0.01,0.02,'4/8 12:00am', 'Finance'], ['American International Group, Inc.',64.13,0.31,0.49,'4/1 12:00am', 'Services'], ['AT&T Inc.',31.61,-0.48,-1.54,'4/8 12:00am', 'Services'], ['Boeing Co.',75.43,0.53,0.71,'4/8 12:00am', 'Manufacturing'], ['Caterpillar Inc.',67.27,0.92,1.39,'4/1 12:00am', 'Services'], ['Citigroup, Inc.',49.37,0.02,0.04,'4/4 12:00am', 'Finance'], ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'4/1 12:00am', 'Manufacturing'], ['Exxon Mobil Corp',68.1,-0.43,-0.64,'4/3 12:00am', 'Manufacturing'], ['General Electric Company',34.14,-0.08,-0.23,'4/3 12:00am', 'Manufacturing'], ['General Motors Corporation',30.27,1.09,3.74,'4/3 12:00am', 'Automotive'], ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'4/3 12:00am', 'Computer'], ['Honeywell Intl Inc',38.77,0.05,0.13,'4/3 12:00am', 'Manufacturing'], ['Intel Corporation',19.88,0.31,1.58,'4/2 12:00am', 'Computer'], ['International Business Machines',81.41,0.44,0.54,'4/1 12:00am', 'Computer'], ['Johnson & Johnson',64.72,0.06,0.09,'4/2 12:00am', 'Medical'], ['JP Morgan & Chase & Co',45.73,0.07,0.15,'4/2 12:00am', 'Finance'], ['McDonald\'s Corporation',36.76,0.86,2.40,'4/2 12:00am', 'Food'], ['Merck & Co., Inc.',40.96,0.41,1.01,'4/2 12:00am', 'Medical'], ['Microsoft Corporation',25.84,0.14,0.54,'4/2 12:00am', 'Computer'], ['Pfizer Inc',27.96,0.4,1.45,'4/8 12:00am', 'Services', 'Medical'], ['The Coca-Cola Company',45.07,0.26,0.58,'4/1 12:00am', 'Food'], ['The Home Depot, Inc.',34.64,0.35,1.02,'4/8 12:00am', 'Retail'], ['The Procter & Gamble Company',61.91,0.01,0.02,'4/1 12:00am', 'Manufacturing'], ['United Technologies Corporation',63.26,0.55,0.88,'4/1 12:00am', 'Computer'], ['Verizon Communications',35.57,0.39,1.11,'4/3 12:00am', 'Services'], ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'4/3 12:00am', 'Retail'], ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'4/1 12:00am', 'Services'] ]; // add in some dummy descriptions for(var i = 0; i < Ext.grid.dummyData.length; i++){ Ext.grid.dummyData[i].push('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.'); }
module.exports={A:{A:{"2":"J C G E UB","1028":"A","1316":"B"},B:{"1":"D X g H L"},C:{"1":"0 2 4 u Y Z a b c d e f K h i j k l m n o p q r w x v z t s","164":"1 SB F I J C G E B A D X g H L M N O P Q QB PB","516":"R S T U V W"},D:{"1":"0 2 4 8 Y Z a b c d e f K h i j k l m n o p q r w x v z t s EB AB TB BB CB","33":"Q R S T U V W u","164":"F I J C G E B A D X g H L M N O P"},E:{"1":"E B A IB JB KB","33":"C G GB HB","164":"7 F I J DB FB"},F:{"1":"M N O P Q R S T U V W u Y Z a b c d e f K h i j k l m n o p q r y","2":"5 6 E A D LB MB NB OB RB","33":"H L"},G:{"1":"A ZB aB bB cB","33":"G XB YB","164":"3 7 9 VB WB"},H:{"1":"dB"},I:{"1":"s iB jB","164":"1 3 F eB fB gB hB"},J:{"1":"B","164":"C"},K:{"1":"K y","2":"5 6 B A D"},L:{"1":"8"},M:{"1":"t"},N:{"1":"A","292":"B"},O:{"164":"kB"},P:{"1":"F I"},Q:{"1":"lB"},R:{"1":"mB"}},B:4,C:"CSS Flexible Box Layout Module"};
import os from django.conf import settings from django.core.management.base import BaseCommand from optparse import make_option from create_indexes import create_indexes from create_locations import <API key> from setconfig import <API key> from <API key> import create_dashboard from crits.core.user_role import UserRole from crits.domains.domain import TLD from crits.indicators.indicator import IndicatorAction from crits.raw_data.raw_data import RawDataType class Command(BaseCommand): """ Script Class. """ option_list = BaseCommand.option_list + ( make_option('--drop', '-d', dest='drop', action="store_true", default=False, help='Drop existing content before adding.'), ) help = 'Creates default CRITs collections in MongoDB.' def handle(self, *args, **options): """ Script Execution. """ drop = options.get('drop') if drop: print "Dropping enabled. Will drop content before adding!" else: print "Drop protection enabled. Will not drop existing content!" populate_user_roles(drop) <API key>(drop) <API key>(drop) # The following will always occur with every run of this script: # - tlds are based off of a Mozilla TLD list so it should never # contain entries outside of the ones provided. populate_tlds(drop) <API key>(drop) create_dashboard(drop) <API key>() create_indexes() def populate_user_roles(drop): """ Populate default set of user roles into the system. :param drop: Drop the existing collection before trying to populate. :type: boolean """ # define your user roles here # note: you MUST have Administrator, Read Only, and a third option # available! user_roles = ['Administrator', 'Analyst', 'Read Only'] if drop: UserRole.drop_collection() if len(UserRole.objects()) < 1: for role in user_roles: ur = UserRole() ur.name = role ur.save() print "User Roles: added %s roles!" % len(user_roles) else: print "User Roles: existing documents detected. skipping!" def <API key>(drop): """ Populate default set of Indicator Actions into the system. :param drop: Drop the existing collection before trying to populate. :type: boolean """ # define your indicator actions here actions = ['Blocked Outbound At Firewall', 'Blocked Outbound At Desktop Firewall'] if drop: IndicatorAction.drop_collection() if len(IndicatorAction.objects()) < 1: for action in actions: ia = IndicatorAction() ia.name = action ia.save() print "Indicator Actions: added %s actions!" % len(actions) else: print "Indicator Actions: existing documents detected. skipping!" def <API key>(drop): """ Populate default set of raw data types into the system. :param drop: Drop the existing collection before trying to populate. :type: boolean """ # define your raw data types here data_types = ['Text', 'JSON'] if drop: RawDataType.drop_collection() if len(RawDataType.objects()) < 1: for data_type in data_types: dt = RawDataType() dt.name = data_type dt.save() print "Raw Data Types: added %s types!" % len(data_types) else: print "Raw Data Types: existing documents detected. skipping!" def populate_tlds(drop): """ Populate default set of TLDs into the system. :param drop: Drop the existing collection before trying to populate. :type: boolean """ if not drop: print "Drop protection does not apply to effective TLDs" TLD.drop_collection() f = os.path.join(settings.SITE_ROOT, '..', 'extras', 'effective_tld_names.dat') count = 0 for line in open(f, 'r').readlines(): line = line.strip() if line and not line.startswith(' TLD.objects(tld=line).update_one(set__tld=line, upsert=True) count += 1 print "Effective TLDs: added %s TLDs!" % count
#ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H #if defined (__GNUC__) || defined (__ICCARM__) #include <stdint.h> #endif #define <API key> 0 #define <API key> 0 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( sysclk_get_cpu_hz() ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define <API key> ( ( unsigned portBASE_TYPE ) 5 ) #define <API key> ( ( unsigned short ) 130 ) #define <API key> ( ( size_t ) 20000 ) #define <API key> ( 16 ) #define <API key> 0 #define <API key> 0 #define <API key> 1 #define configUSE_MUTEXES 0 #define <API key> 5 #define <API key> 1 #define <API key> 0 #define <API key> 1 #define <API key> 1 #define <API key> 0 /* Co-routine definitions. */ #define <API key> 0 #define <API key> ( 2 ) /* Software timer definitions. */ #define configUSE_TIMERS 1 #define <API key> ( <API key> - 1 ) #define <API key> 5 #define <API key> ( <API key> * 3 ) /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ #define <API key> 1 #define <API key> 1 #define INCLUDE_vTaskDelete 1 #define <API key> 1 #define <API key> 1 #define <API key> 1 #define INCLUDE_vTaskDelay 1 #define <API key> 1 #define <API key> 1 /* FreeRTOS+CLI definitions. */ /* Dimensions a buffer into which command outputs can be written. The buffer can be declared in the CLI code itself, to allow multiple command consoles to share the same buffer. For example, an application may allow access to the command interpreter by UART and by Ethernet. Sharing a buffer is done purely to save RAM. Note, however, that the command console itself is not re-entrant, so only one command interpreter interface can be used at any one time. For that reason, no attempt at providing mutual exclusion to the buffer is attempted. */ #define <API key> 400 /* Cortex-M specific definitions. */ #ifdef __NVIC_PRIO_BITS /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ #define configPRIO_BITS __NVIC_PRIO_BITS #else #define configPRIO_BITS 4 /* 15 priority levels */ #endif /* The lowest interrupt priority that can be used in a call to a "set priority" function. */ #define <API key> 0x0f /* The highest interrupt priority that can be used by any interrupt service routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER PRIORITY THAN THIS! (higher priorities are lower numeric values. */ #define <API key> 10 /* Interrupt priorities used by the kernel port layer itself. These are generic to all Cortex-M ports, and do not rely on any particular library functions. */ #define <API key> ( <API key> << (8 - configPRIO_BITS) ) #define <API key> ( <API key> << (8 - configPRIO_BITS) ) /* Normal assert() semantics without relying on the provision of an assert.h header file. */ #define configASSERT( x ) //if( ( x ) == 0 ) { <API key>(); for( ;; ) __asm volatile( "NOP" ); } #define INCLUDE_MODULE_TEST 0 //#include "trcHooks.h" #endif /* FREERTOS_CONFIG_H */
<a href='https://github.com/angular/angular.js/edit/v1.4.x/src/ngTouch/directive/ngClick.js?message=docs(ngClick)%3A%20describe%20your%20change...#L7' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this Doc</a> <a href='https://github.com/angular/angular.js/tree/v1.4.4/src/ngTouch/directive/ngClick.js#L7' class='view-source pull-right btn btn-primary'> <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source </a> <header class="api-profile-header"> <h1 class="<API key>">ngClick</h1> <ol class="<API key> naked-list step-list"> <li> - directive in module <a href="api/ngTouch">ngTouch</a> </li> </ol> </header> <div class="<API key>"> <p>A more powerful replacement for the default ngClick designed to be used on touchscreen devices. Most mobile browsers wait about 300ms after a tap-and-release before sending the click event. This version handles them immediately, and then prevents the following click event from propagating.</p> <p>Requires the <a href="api/ngTouch"><code>ngTouch</code></a> module to be installed.</p> <p>This directive can fall back to using an ordinary click event, and so works on desktop browsers as well as mobile.</p> <p>This directive also sets the CSS class <code>ng-click-active</code> while the element is being held down (by a mouse click or touch) so you can restyle the depressed element if you wish.</p> </div> <div> <h2>Directive Info</h2> <ul> <li>This directive executes at priority level 0.</li> </ul> <h2 id="usage">Usage</h2> <div class="usage"> <ul> <li>as attribute: <pre><code>&lt;ANY&#10; ng-click=&quot;expression&quot;&gt;&#10;...&#10;&lt;/ANY&gt;</code></pre> </li> </div> <section class="api-section"> <h3>Arguments</h3> <table class="variables-matrix input-arguments"> <thead> <tr> <th>Param</th> <th>Type</th> <th>Details</th> </tr> </thead> <tbody> <tr> <td> ngClick </td> <td> <a href="" class="label type-hint <API key>">expression</a> </td> <td> <p><a href="guide/expression">Expression</a> to evaluate upon tap. (Event object is available as <code>$event</code>)</p> </td> </tr> </tbody> </table> </section> <h2 id="example">Example</h2><p> <div> <a ng-click="openPlunkr('examples/example-example116', $event)" class="btn pull-right"> <i class="glyphicon glyphicon-edit">&nbsp;</i> Edit in Plunker</a> <div class="runnable-example" path="examples/example-example116" module="ngClickExample" deps="angular-touch.js"> <div class="<API key>" name="index.html" language="html" type="html"> <pre><code>&lt;button ng-click=&quot;count = count + 1&quot; ng-init=&quot;count=0&quot;&gt;&#10; Increment&#10;&lt;/button&gt;&#10;count: {{ count }}</code></pre> </div> <div class="<API key>" name="script.js" language="js" type="js"> <pre><code>angular.module(&#39;ngClickExample&#39;, [&#39;ngTouch&#39;]);</code></pre> </div> <iframe class="<API key>" src="examples/example-example116/index.html" name="example-example116"></iframe> </div> </div> </p> </div>
#ifndef <API key> #define <API key> #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/functional/partial.hpp> #include <cstddef> <API key> //! @ingroup group-functional //! Applies another function `n` times to its argument. //! Given a function `f` and an argument `x`, `iterate<n>(f, x)` returns //! the result of applying `f` `n` times to its argument. In other words, //! @code //! iterate<n>(f, x) == f(f( ... f(x))) //! ^^^^^^^^^^ n times total //! @endcode //! If `n == 0`, `iterate<n>(f, x)` returns the `x` argument unchanged //! and `f` is never applied. It is important to note that the function //! passed to `iterate<n>` must be a unary function. Indeed, since `f` //! will be called with the result of the previous `f` application, it //! may only take a single argument. //! In addition to what's documented above, `iterate` can also be //! partially applied to the function argument out-of-the-box. In //! other words, `iterate<n>(f)` is a function object applying `f` //! `n` times to the argument it is called with, which means that //! @code //! iterate<n>(f)(x) == iterate<n>(f, x) //! @endcode //! This is provided for convenience, and it turns out to be especially //! useful in conjunction with higher-order algorithms. //! Signature //! Given a function \f$ f : T \to T \f$ and `x` and argument of data //! type `T`, the signature is //! \mathtt{iterate_n} : (T \to T) \times T \to T //! @tparam n //! An unsigned integer representing the number of times that `f` //! should be applied to its argument. //! @param f //! A function to apply `n` times to its argument. //! @param x //! The initial value to call `f` with. //! Example //! @include example/functional/iterate.cpp #ifdef <API key> template <std::size_t n> constexpr auto iterate = [](auto&& f) { return [perfect-capture](auto&& x) -> decltype(auto) { return f(f( ... f(forwarded(x)))); }; }; #else template <std::size_t n, typename = when<true>> struct iterate_t; template <> struct iterate_t<0> { template <typename F, typename X> constexpr X operator()(F&&, X&& x) const { return static_cast<X&&>(x); } }; template <> struct iterate_t<1> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return f(static_cast<X&&>(x)); } }; template <> struct iterate_t<2> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return f(f(static_cast<X&&>(x))); } }; template <> struct iterate_t<3> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return f(f(f(static_cast<X&&>(x)))); } }; template <> struct iterate_t<4> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return f(f(f(f(static_cast<X&&>(x))))); } }; template <> struct iterate_t<5> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return f(f(f(f(f(static_cast<X&&>(x)))))); } }; template <std::size_t n> struct iterate_t<n, when<(n >= 6) && (n < 12)>> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return iterate_t<n - 6>{}(f, f(f(f(f(f(f(static_cast<X&&>(x))))))) ); } }; template <std::size_t n> struct iterate_t<n, when<(n >= 12) && (n < 24)>> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return iterate_t<n - 12>{}(f, f(f(f(f(f(f(f(f(f(f(f(f( static_cast<X&&>(x) )))))))))))) ); } }; template <std::size_t n> struct iterate_t<n, when<(n >= 24) && (n < 48)>> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return iterate_t<n - 24>{}(f, f(f(f(f(f(f(f(f(f(f(f(f( f(f(f(f(f(f(f(f(f(f(f(f( static_cast<X&&>(x) )))))))))))) )))))))))))) ); } }; template <std::size_t n> struct iterate_t<n, when<(n >= 48)>> { template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return iterate_t<n - 48>{}(f, f(f(f(f(f(f(f(f(f(f(f(f( f(f(f(f(f(f(f(f(f(f(f(f( f(f(f(f(f(f(f(f(f(f(f(f( f(f(f(f(f(f(f(f(f(f(f(f( static_cast<X&&>(x) )))))))))))) )))))))))))) )))))))))))) )))))))))))) ); } }; template <std::size_t n> struct make_iterate_t { template <typename F> constexpr decltype(auto) operator()(F&& f) const { return hana::partial(iterate_t<n>{}, static_cast<F&&>(f)); } template <typename F, typename X> constexpr decltype(auto) operator()(F&& f, X&& x) const { return iterate_t<n>{}(static_cast<F&&>(f), static_cast<X&&>(x)); } }; template <std::size_t n> constexpr make_iterate_t<n> iterate{}; #endif <API key> #endif // !<API key>
module Spaceship::TestFlight class BetaReviewInfo < Base attr_accessor :contact_first_name, :contact_last_name, :contact_phone, :contact_email attr_accessor :demo_account_name, :<API key>, :<API key>, :notes attr_mapping({ 'contactFirstName' => :contact_first_name, 'contactLastName' => :contact_last_name, 'contactPhone' => :contact_phone, 'contactEmail' => :contact_email, 'demoAccountName' => :demo_account_name, 'demoAccountPassword' => :<API key>, 'demoAccountRequired' => :<API key>, 'notes' => :notes }) end end
<?php declare(strict_types=1); namespace Sylius\Bundle\CurrencyBundle\Form\Type; use Sylius\Bundle\ResourceBundle\Form\Type\<API key>; use Sylius\Component\Currency\Model\<API key>; use Symfony\Component\Form\Extension\Core\DataTransformer\<API key>; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\Form\<API key>; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\OptionsResolver\OptionsResolver; final class ExchangeRateType extends <API key> { /** * {@inheritdoc} */ public function buildForm(<API key> $builder, array $options): void { $builder ->add('ratio', NumberType::class, [ 'label' => 'sylius.form.exchange_rate.ratio', 'required' => true, 'invalid_message' => 'sylius.exchange_rate.ratio.invalid', 'scale' => 5, 'rounding_mode' => $options['rounding_mode'], ]) ; $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { /** @var <API key> $exchangeRate */ $exchangeRate = $event->getData(); $form = $event->getForm(); $disabled = null !== $exchangeRate->getId(); $form ->add('sourceCurrency', CurrencyChoiceType::class, [ 'label' => 'sylius.form.exchange_rate.source_currency', 'required' => true, 'empty_data' => false, 'disabled' => $disabled, ]) ->add('targetCurrency', CurrencyChoiceType::class, [ 'label' => 'sylius.form.exchange_rate.target_currency', 'required' => true, 'empty_data' => false, 'disabled' => $disabled, ]) ; }); } /** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver): void { parent::configureOptions($resolver); $resolver->setDefault('rounding_mode', <API key>::ROUND_HALF_EVEN); } /** * {@inheritdoc} */ public function getBlockPrefix() { return '<API key>'; } }
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Uses of Package org.apache.commons.math3.analysis.differentiation (Apache Commons Math 3.6.1 API)</title> <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="Uses of Package org.apache.commons.math3.analysis.differentiation (Apache Commons Math 3.6.1 API)"; } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <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</li> <li class="navBarCell1Rev">Use</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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=<API key>"></script></em></div> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/commons/math3/analysis/differentiation/package-use.html" target="_top">Frames</a></li> <li><a href="package-use.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip-navbar_top"> </a></div> <div class="header"> <h1 title="Uses of Package org.apache.commons.math3.analysis.differentiation" class="title">Uses of Package<br>org.apache.commons.math3.analysis.differentiation</h1> </div> <div class="contentContainer"> <ul class="blockList"> <li class="blockList"> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation"> <caption><span>Packages that use <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis">org.apache.commons.math3.analysis</a></td> <td class="colLast"> <div class="block"> Parent package for common numerical analysis procedures, including root finding, function interpolation and integration.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis.differentiation">org.apache.commons.math3.analysis.differentiation</a></td> <td class="colLast"> <div class="block"> This package holds the main interfaces and basic building block classes dealing with differentiation.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis.function">org.apache.commons.math3.analysis.function</a></td> <td class="colLast"> <div class="block"> The <code>function</code> package contains function objects that wrap the methods contained in <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html?is-external=true" title="class or interface in java.lang"><code>Math</code></a>, as well as common mathematical functions such as the gaussian and sinc functions.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis.interpolation">org.apache.commons.math3.analysis.interpolation</a></td> <td class="colLast"> <div class="block">Univariate real functions interpolation algorithms.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis.polynomials">org.apache.commons.math3.analysis.polynomials</a></td> <td class="colLast"> <div class="block">Univariate real polynomials implementations, seen as differentiable univariate real functions.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#org.apache.commons.math3.analysis.solvers">org.apache.commons.math3.analysis.solvers</a></td> <td class="colLast"> <div class="block">Root finding algorithms, for univariate real functions.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="#org.apache.commons.math3.optimization.general">org.apache.commons.math3.optimization.general</a></td> <td class="colLast"> <div class="block">This package provides optimization algorithms that require derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/package-summary.html">org.apache.commons.math3.analysis</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable real function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable vectorial function.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis"><API key></a> <div class="block">Interface for univariate functions derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis.differentiation"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DerivativeStructure.html#org.apache.commons.math3.analysis.differentiation">DerivativeStructure</a> <div class="block">Class representing both the value and the differentials of a function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DSCompiler.html#org.apache.commons.math3.analysis.differentiation">DSCompiler</a> <div class="block">Class holding "compiled" computation rules for derivative structures.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable real function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable vectorial function.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/SparseGradient.html#org.apache.commons.math3.analysis.differentiation">SparseGradient</a> <div class="block">First derivative computation with large number of variables.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Interface for univariate functions derivatives.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a univariate differentiable matrix function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a univariate differentiable vectorial function.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Interface defining the function differentiation operation.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Interface defining the function differentiation operation.</div> </td> </tr> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.differentiation"><API key></a> <div class="block">Interface defining the function differentiation operation.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis.function"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/function/package-summary.html">org.apache.commons.math3.analysis.function</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DerivativeStructure.html#org.apache.commons.math3.analysis.function">DerivativeStructure</a> <div class="block">Class representing both the value and the differentials of a function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.function"><API key></a> <div class="block">Interface for univariate functions derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis.interpolation"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/interpolation/package-summary.html">org.apache.commons.math3.analysis.interpolation</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DerivativeStructure.html#org.apache.commons.math3.analysis.interpolation">DerivativeStructure</a> <div class="block">Class representing both the value and the differentials of a function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.interpolation"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a univariate differentiable vectorial function.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis.polynomials"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/polynomials/package-summary.html">org.apache.commons.math3.analysis.polynomials</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DerivativeStructure.html#org.apache.commons.math3.analysis.polynomials">DerivativeStructure</a> <div class="block">Class representing both the value and the differentials of a function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.polynomials"><API key></a> <div class="block">Interface for univariate functions derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.analysis.solvers"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/analysis/solvers/package-summary.html">org.apache.commons.math3.analysis.solvers</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/DerivativeStructure.html#org.apache.commons.math3.analysis.solvers">DerivativeStructure</a> <div class="block">Class representing both the value and the differentials of a function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.analysis.solvers"><API key></a> <div class="block">Interface for univariate functions derivatives.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="org.apache.commons.math3.optimization.general"> </a> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../../org/apache/commons/math3/analysis/differentiation/package-summary.html">org.apache.commons.math3.analysis.differentiation</a> used by <a href="../../../../../../org/apache/commons/math3/optimization/general/package-summary.html">org.apache.commons.math3.optimization.general</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.optimization.general"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable real function.</div> </td> </tr> <tr class="rowColor"> <td class="colOne"><a href="../../../../../../org/apache/commons/math3/analysis/differentiation/class-use/<API key>.html#org.apache.commons.math3.optimization.general"><API key></a> <div class="block">Extension of <a href="../../../../../../org/apache/commons/math3/analysis/<API key>.html" title="interface in org.apache.commons.math3.analysis"><code><API key></code></a> representing a multivariate differentiable vectorial function.</div> </td> </tr> </tbody> </table> </li> </ul> </div> <div class="bottomNav"><a name="navbar_bottom"> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>"> </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</li> <li class="navBarCell1Rev">Use</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 class="aboutLanguage"><em><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=<API key>"></script></em></div> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../../index.html?org/apache/commons/math3/analysis/differentiation/package-use.html" target="_top">Frames</a></li> <li><a href="package-use.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <a name="skip-navbar_bottom"> </a></div> <p class="legalCopy"><small>Copyright & </body> </html>
namespace UltimateTeam.Toolkit.Models { public class Shards { public ShardInfo ShardInfo { get; set; } } }
namespace Umbraco.Core.Configuration.UmbracoSettings { public interface ITemplatesSection : <API key> { bool <API key> { get; } bool EnableSkinSupport { get; } RenderingEngine <API key> { get; } bool <API key> { get; } } }
require 'test_helper' class <API key> < Test::Unit::TestCase include OffsitePayments::Integrations def setup @world_pay = WorldPay::Notification.new(http_raw_data) end def test_accessors assert @world_pay.complete? assert_equal "Completed", @world_pay.status assert_equal "1234123412341234", @world_pay.transaction_id assert_equal "1", @world_pay.item_id assert_equal "5.00", @world_pay.gross assert_equal "GBP", @world_pay.currency assert_equal Time.utc('2007-01-01 00:00:00').utc, @world_pay.received_at assert @world_pay.test? end def test_compositions assert_equal Money.new(500, 'GBP'), @world_pay.amount end def <API key> assert_equal "Andrew White", @world_pay.name assert_equal "1 Nowhere Close", @world_pay.address assert_equal "CV1 1AA", @world_pay.postcode assert_equal "GB", @world_pay.country assert_equal "024 7699 9999", @world_pay.phone_number assert_equal "024 7699 9999", @world_pay.fax_number assert_equal "andyw@example.com", @world_pay.email_address assert_equal "Mastercard", @world_pay.card_type end def <API key> assert @world_pay.respond_to?(:acknowledge) end def <API key> notification = WorldPay::Notification.new('transStatus=Y') assert_equal 'Completed', notification.status end def <API key> notification = WorldPay::Notification.new('transStatus=C') assert_equal 'Cancelled', notification.status end def <API key> assert_equal 'password', @world_pay.security_key end def <API key> assert_equal :matched, @world_pay.cvv_status assert_equal :matched, @world_pay.postcode_status assert_equal :matched, @world_pay.address_status assert_equal :matched, @world_pay.country_status end def <API key> notification = WorldPay::Notification.new("M_custom_1=Custom Value 1&MC_custom_2=Custom Value 2&CM_custom_3=Custom Value 3") assert_equal 'Custom Value 1', notification.custom_params[:custom_1] assert_equal 'Custom Value 2', notification.custom_params[:custom_2] assert_equal 'Custom Value 3', notification.custom_params[:custom_3] end private def http_raw_data "transId=1234123412341234&transStatus=Y&currency=GBP&transTime=1167609600000&testMode=100&authAmount=5.00&cartId=1&authCurrency=GBP&callbackPW=password&countryMatch=Y&AVS=2222&cardType=Mastercard&name=Andrew White&address=1 Nowhere Close&postcode=CV1 1AA&country=GB&tel=024 7699 9999&fax=024 7699 9999&email=andyw@example.com" end end
/** * The `username` helper displays a user's username in a <span class="username"> * tag. If the user doesn't exist, the username will be displayed as [deleted]. * * @param {User} user * @return {Object} */ export default function username(user) { const name = (user && user.username()) || app.translator.trans('core.lib.username.deleted_text'); return <span className="username">{name}</span>; }
#ifndef Sha256_h #define Sha256_h #include <inttypes.h> #include "Print.h" #define HASH_LENGTH 32 #define BLOCK_LENGTH 64 union _buffer { uint8_t b[BLOCK_LENGTH]; uint32_t w[BLOCK_LENGTH/4]; }; union _state { uint8_t b[HASH_LENGTH]; uint32_t w[HASH_LENGTH/4]; }; class Sha256Class : public Print { public: void init(void); void initHmac(const uint8_t* secret, int secretLength); uint8_t* result(void); uint8_t* resultHmac(void); virtual size_t write(uint8_t); using Print::write; private: void pad(); void addUncounted(uint8_t data); void hashBlock(); uint32_t ror32(uint32_t number, uint8_t bits); _buffer buffer; uint8_t bufferOffset; _state state; uint32_t byteCount; uint8_t keyBuffer[BLOCK_LENGTH]; uint8_t innerHash[HASH_LENGTH]; }; extern Sha256Class Sha256; #endif
var specializer = require('../lib/specializer'), assert = require('assert'), testSet = require('./fixtures/testInputs.json'), mocha = require('mocha'); describe('Specializer', function () { describe('resolve Tests', function () { var spcl, config, context; it('should test invoking module to rule Evaluate', function () { spcl = specializer.create(testSet['testRequire'].config); assert.equal('foo/partial1', spcl.resolve('partialSamples/partial1', testSet['testRequire'].context)); }); it('should test invoking a factory API to rule Evaluate', function () { spcl = specializer.create(testSet['testExec'].config); assert.equal('foo/partial1', spcl.resolve('partialSamples/partial1', testSet['testExec'].context)); }); it('should test in res.locals to rule Evaluate', function() { config = testSet['testLocal'].config; context = testSet['testLocal'].context; spcl = specializer.create(config); assert.equal('bar/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test simple no matched specialized template case', function () { context.experiments = ['blah']; spcl = specializer.create(config); assert.equal('partialSamples/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test for simple matched template case', function () { context.experiments = ['foo']; assert.equal('bar/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test with complex no matched case', function () { config['partialSamples/partial1'][1].when.experiments = ['foo', ['bar', 'blah']], context.experiments = ['blue', 'yellow']; spcl = specializer.create(config); assert.equal('partialSamples/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test for complex matched case to resolve templates', function () { config['partialSamples/partial1'][1].when.experiments = ['foo', ['bar', 'blah']]; context.experiments = ['blah', 'bar']; spcl = specializer.create(config); assert.equal('bar/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test for a simple match even when a complex entry is specified in config', function () { context.experiments = ['foo', 'blah']; assert.equal('bar/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test cases where config is a non array and matches', function () { config['partialSamples/partial1'][1].when.isMonthOfAugust = true; context.isMonthOfAugust = true; spcl = specializer.create(config); assert.equal('bar/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test cases where config is a non array and failed to match', function () { config['partialSamples/partial1'][1].when.krakenIs = 'angryOctopus'; context.krakenIs = 'happyOctopus'; spcl = specializer.create(config); assert.equal('partialSamples/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test cases where config is a spec like kraken.Is.Angry.beware', function () { config = testSet['testComplexLocal'].config; context = testSet['testComplexLocal'].context; spcl = specializer.create(config); assert.equal('bal/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test cases where config is a spec like kraken.Is.Angry.beware and rules dont match', function () { config = testSet['testComplexLocal'].config; context = testSet['testComplexLocal'].context.kraken.is = 'happy'; spcl = specializer.create(config); assert.equal('partialSamples/partial1', spcl.resolve('partialSamples/partial1', context)); }); it('should test when the template is not in the specialization config', function () { config = testSet['testComplexLocal'].config; context = testSet['testComplexLocal'].context.kraken.is = 'happy'; spcl = specializer.create(config); assert.equal('foo', spcl.resolve('foo', context)); }); it('should test invoking a factory API to rule Evaluate and return falsy', function () { spcl = specializer.create(testSet['testExecFalsy'].config); assert.equal('partialSamples/partial1', spcl.resolve('partialSamples/partial1', testSet['testExecFalsy'].context)); }); }); describe('resolveAll Tests', function () { var map, config = testSet['testResolveAll'].config, spcl; it('should test returning empty map when none of the templates match', function () { context = { locale: 'en_AU', device: 'tablet', experiments: ['foo', 'bar'] }; spcl = specializer.create(config); assert.deepEqual({}, spcl.resolveAll(context)); }); it('should test returning a valid map when some of the templates match', function () { context = { locale: 'en_US', device: 'tablet', experiments: ['foo', 'bar'] }; spcl = specializer.create(config); assert.deepEqual({'partialSamples/partial1':'bar/partial1','partialSamples/partial2':'bal/partial2','partialSamples/partial3':'bar/partial3'}, spcl.resolveAll(context)); }); }); });
Add-Type -AssemblyName System.Security $nuGetTempDirectory = Join-Path $Env:<API key> "NuGet\" $tempNuGetConfigPath = Join-Path $nuGetTempDirectory "newNuGet.config" function SaveTempNuGetConfig { [CmdletBinding()] param( [xml] $nugetConfig ) if(-not (Test-Path -Path ($nuGetTempDirectory))) { Write-Verbose "Creating NuGet directory: $nuGetTempDirectory" New-Item -Path $nuGetTempDirectory -ItemType Directory } Write-Host (Get-LocalizedString -Key "Saving to {0}" -ArgumentList $tempNuGetConfigPath) $nugetConfig.Save($tempNuGetConfigPath) } function <API key> { [CmdletBinding()] param( [string] $password ) [Convert]::ToBase64String( [System.Security.Cryptography.ProtectedData]::Protect( [Text.Encoding]::UTF8.GetBytes($password), [Text.Encoding]::UTF8.GetBytes("NuGet"), [System.Security.Cryptography.DataProtectionScope]::CurrentUser)); } function <API key> { [CmdletBinding()] param( [xml] $nugetConfig, [System.Xml.XmlElement] $credentialsSection, [string] $credentialKey, [string] $password ) $newCredential = $nugetConfig.CreateElement($credentialKey) $userNameElement= $nugetConfig.CreateElement("add") [void]$userNameElement.SetAttribute("key", "UserName") [void]$userNameElement.SetAttribute("value", "VssSessionToken") [void]$newCredential.AppendChild($userNameElement) $passwordElement = $nugetConfig.CreateElement("add") [void]$passwordElement.SetAttribute("key", "Password") $encrypted<API key> $password [void]$passwordElement.SetAttribute("value", $encryptedPassword) [void]$newCredential.AppendChild($passwordElement) [void]$credentialsSection.AppendChild($newCredential) } function <API key> { [CmdletBinding()] param( [Uri]$feedUri ) if(-not ($feedUri.Scheme.Equals("http","<API key>") -or $feedUri.Scheme.Equals("https","<API key>"))) { return $false } $WebRequestObject = [System.Net.HttpWebRequest] [System.Net.WebRequest]::Create($feedUri); try { $ResponseObject = [System.Net.HttpWebResponse] $WebRequestObject.GetResponse(); } catch [Net.WebException] { $ResponseObject = [System.Net.HttpWebResponse] $_.Exception.Response } if($ResponseObject.StatusCode -eq 401) { $tfsHeaderPresent = $false $vssHeaderPresent = $false foreach($key in $ResponseObject.Headers.AllKeys) { if($tfsHeaderPresent -or $key.Contains("X-TFS")) { $tfsHeaderPresent = $true } if($vssHeaderPresent -or $key.Contains("X-VSS")) { $vssHeaderPresent = $true } if($tfsHeaderPresent -and $vssHeaderPresent) { break } } [void]$ResponseObject.Close(); return $tfsHeaderPresent -and $vssHeaderPresent } return $false } function <API key> { [CmdletBinding()] param( [xml] $nugetConfig, [string] $accessToken, [uri]$targetFeed ) $credentialsSection = $nugetConfig.SelectSingleNode("configuration/<API key>") if($credentialsSection -eq $null) { Write-Verbose "Adding credentials section to NuGet.config" #add the <API key> node $credentialsSection = $nugetConfig.CreateElement("<API key>") [void]$nugetConfig.configuration.AppendChild($credentialsSection) } $nugetSources = $nugetConfig.SelectNodes("configuration/packageSources/add") foreach($nugetSource in $nugetSources) { if($targetFeed -and (-not $targetFeed.ToString().Equals($nugetSource.value,"<API key>"))) { Write-Verbose "Source ($nugetSource) skipped, it is not target ($targetFeed)" continue } if(-not (<API key> $nugetSource.value)) { continue } [string]$encodedSource = [System.Xml.XmlConvert]::EncodeLocalName([string]$nugetSource.key) if($credentialsSection.SelectSingleNode($encodedSource) -ne $null) { $credentials = $credentialsSection.SelectSingleNode($encodedSource) foreach($section in $credentials.SelectNodes("add")) { if([string]::Equals(([System.Xml.XmlNode]$section).Attributes["key"].Value, "password", "<API key>")) { Write-Verbose "Setting new credential for $encodedSource" $encrypted<API key> $accessToken ([System.Xml.XmlNode]$section).Attributes["value"].Value = $encryptedPassword } } } else { Write-Host (Get-LocalizedString -Key "Setting credentials for {0}" -ArgumentList $([string]$nugetSource.key)) <API key> $nugetConfig $credentialsSection $encodedSource $accessToken } } SaveTempNuGetConfig $nugetConfig }
import * as React from 'react'; import { IconBaseProps } from 'react-icon-base'; export default class IoIosCloudOutline extends React.Component<IconBaseProps, any> { }
class ViewTitleScreen < PM::Screen attr_accessor :<API key> title UIView.alloc.init def will_appear self.<API key> = false add UILabel.alloc.initWithFrame([[ 10, 10 ], [ 300, 40 ]]), text: "Label Here" end def triggered_button self.<API key> = true end end
"use strict"; var <API key> = require("@babel/runtime/helpers/<API key>").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.CellButton = void 0; var _jsxRuntime = require("../../lib/jsxRuntime"); var _extends2 = <API key>(require("@babel/runtime/helpers/extends")); var _defineProperty2 = <API key>(require("@babel/runtime/helpers/defineProperty")); var <API key> = <API key>(require("@babel/runtime/helpers/<API key>")); var _getClassName = require("../../helpers/getClassName"); var _classNames2 = require("../../lib/classNames"); var _usePlatform = require("../../hooks/usePlatform"); var _SimpleCell = <API key>(require("../SimpleCell/SimpleCell")); var _excluded = ["centered", "mode"]; var CellButton = function CellButton(_ref) { var _ref$centered = _ref.centered, centered = _ref$centered === void 0 ? false : _ref$centered, _ref$mode = _ref.mode, mode = _ref$mode === void 0 ? "primary" : _ref$mode, restProps = (0, <API key>.default)(_ref, _excluded); var platform = (0, _usePlatform.usePlatform)(); return (0, _jsxRuntime.createScopedElement)(_SimpleCell.default, (0, _extends2.default)({ stopPropagation: true }, restProps, { vkuiClass: (0, _classNames2.classNames)((0, _getClassName.getClassName)("CellButton", platform), "CellButton--".concat(mode), (0, _defineProperty2.default)({}, "<API key>", centered)) })); }; exports.CellButton = CellButton; //# sourceMappingURL=CellButton.js.map
package org.openhab.binding.ihc.internal.converters; import static org.junit.Assert.assertEquals; import org.eclipse.smarthome.core.library.types.OpenClosedType; import org.eclipse.smarthome.core.types.Type; import org.junit.Test; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; /** * Test for IHC / ELKO binding * * @author Pauli Anttila - Initial contribution */ public class <API key> { @Test public void testOpen() throws ConversionException { final boolean inverted = false; WSBooleanValue val = new WSBooleanValue(12345, false); val = convertFromOHType(val, OpenClosedType.OPEN, new <API key>(null, inverted, null)); assertEquals(12345, val.resourceID); assertEquals(true, val.value); OpenClosedType type = <API key>(val, new <API key>(null, inverted, null)); assertEquals(OpenClosedType.OPEN, type); } @Test public void testClosed() throws ConversionException { final boolean inverted = false; WSBooleanValue val = new WSBooleanValue(12345, true); val = convertFromOHType(val, OpenClosedType.CLOSED, new <API key>(null, inverted, null)); assertEquals(12345, val.resourceID); assertEquals(false, val.value); OpenClosedType type = <API key>(val, new <API key>(null, inverted, null)); assertEquals(OpenClosedType.CLOSED, type); } @Test public void testOpenInverted() throws ConversionException { final boolean inverted = true; WSBooleanValue val = new WSBooleanValue(12345, true); val = convertFromOHType(val, OpenClosedType.OPEN, new <API key>(null, inverted, null)); assertEquals(12345, val.resourceID); assertEquals(false, val.value); OpenClosedType type = <API key>(val, new <API key>(null, inverted, null)); assertEquals(OpenClosedType.OPEN, type); } @Test public void testClosedInverted() throws ConversionException { final boolean inverted = true; WSBooleanValue val = new WSBooleanValue(12345, false); val = convertFromOHType(val, OpenClosedType.CLOSED, new <API key>(null, inverted, null)); assertEquals(12345, val.resourceID); assertEquals(true, val.value); OpenClosedType type = <API key>(val, new <API key>(null, inverted, null)); assertEquals(OpenClosedType.CLOSED, type); } private WSBooleanValue convertFromOHType(WSBooleanValue IHCvalue, Type OHval, <API key> <API key>) throws ConversionException { Converter<WSResourceValue, Type> converter = ConverterFactory.getInstance().getConverter(IHCvalue.getClass(), OpenClosedType.class); return (WSBooleanValue) converter.convertFromOHType(OHval, IHCvalue, <API key>); } private OpenClosedType <API key>(WSBooleanValue IHCvalue, <API key> <API key>) throws ConversionException { Converter<WSResourceValue, Type> converter = ConverterFactory.getInstance().getConverter(IHCvalue.getClass(), OpenClosedType.class); return (OpenClosedType) converter.<API key>(IHCvalue, <API key>); } }
package org.eclipse.smarthome.automation.parser.gson.internal; import java.util.List; import org.eclipse.smarthome.automation.dto.<API key>; import org.eclipse.smarthome.automation.dto.<API key>; import org.eclipse.smarthome.automation.dto.<API key>; /** * This is a helper data structure for GSON that represents the JSON format used when having different module types * within a single input stream. * * @author Kai Kreuzer - Initial contribution */ public class <API key> { public List<<API key>> triggers; public List<<API key>> conditions; public List<<API key>> actions; }
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; //font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } a { text-decoration: none; } .cf { zoom: 1; } .cf:after { content: ""; display: block; clear: both; }
package org.eclipse.smarthome.binding.mqtt.internal.ssl; import java.security.<API key>; import java.security.<API key>; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.smarthome.io.transport.mqtt.sslcontext.SSLContextProvider; import org.osgi.service.cm.<API key>; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This is an implementation of the {@link SSLContextProvider}. The {@link PinTrustManager} * will be used for the SSLContext. This implementation forces a TLS 1.2 context. * * @author David Graeff - Initial contribution */ @NonNullByDefault public class <API key> implements SSLContextProvider { private final Logger logger = LoggerFactory.getLogger(<API key>.class); final PinTrustManager trustManager; public <API key>(PinTrustManager pinTrustManager) { this.trustManager = pinTrustManager; } @Override public SSLContext getContext() throws <API key> { try { SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, new TrustManager[] { trustManager }, new java.security.SecureRandom()); return sslContext; } catch (<API key> | <API key> e) { logger.warn("SSL configuration failed", e); throw new <API key>("ssl", e.getMessage()); } } }
package de.vogella.birt.stocks.rcp; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; /** * This class controls all aspects of the application's execution */ public class Application implements IApplication { /* (non-Javadoc) * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) */ public Object start(IApplicationContext context) { Display display = PlatformUI.createDisplay(); try { int returnCode = PlatformUI.<API key>(display, new <API key>()); if (returnCode == PlatformUI.RETURN_RESTART) { return IApplication.EXIT_RESTART; } return IApplication.EXIT_OK; } finally { display.dispose(); } } /* (non-Javadoc) * @see org.eclipse.equinox.app.IApplication#stop() */ public void stop() { final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; final Display display = workbench.getDisplay(); display.syncExec(new Runnable() { public void run() { if (!display.isDisposed()) workbench.close(); } }); } }
package factory; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.impl.AESCipherImpl; import org.eclipse.emf.ecore.xmi.XMIResource; import org.eclipse.emf.ecore.xmi.impl.<API key>; public class MyXMIFactoryImpl extends <API key> { @Override public Resource createResource(URI uri) { <API key> resFactory = new <API key>(); XMIResource resource = (XMIResource) resFactory.createResource(uri); try { resource.<API key>().put(Resource.OPTION_CIPHER, new AESCipherImpl("12345")); resource.<API key>().put(Resource.OPTION_CIPHER, new AESCipherImpl("12345")); } catch (Exception e) { e.printStackTrace(); } return resource; } }
#!/bin/sh >/dev/watchdog export PATH=/sbin:/bin:/usr/sbin:/usr/bin strstr() { [ "${1##*"$2"*}" != "$1" ]; } CMDLINE=$(while read line || [ -n "$line" ]; do echo $line;done < /proc/cmdline) plymouth --quit exec >/dev/console 2>&1 echo "<API key>" >/dev/sdb export TERM=linux export PS1='initramfs-test:\w\$ ' [ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab [ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab stty sane echo "made it to the rootfs!" if strstr "$CMDLINE" "rd.shell"; then strstr "$(setsid --help)" "control" && CTTY="-c" setsid $CTTY sh -i fi echo "Powering down." mount -n -o remount,ro / poweroff -f
#include <linux/slab.h> /* kmalloc, kfree */ #include <linux/jiffies.h> #include <linux/sched.h> #include <linux/wait.h> #include "driver.h" #include "device.h" #include "session.h" v3d_session_t *v3d_session_create(v3d_driver_t *driver, const char *name) { v3d_session_t *instance = (v3d_session_t *) kmalloc(sizeof(v3d_session_t), GFP_KERNEL); if (instance == NULL) return NULL; instance->initialised = 0; /* Unconditional initialisation */ instance->driver = driver; instance->name = name; instance->last_id = 0; INIT_LIST_HEAD(&instance->issued.list); instance->performance_counter.enables = 0; <API key>(instance); /* Initialisation that can fail */ if (<API key>(instance->driver, instance) != 0) return v3d_session_delete(instance), NULL; ++instance->initialised; return instance; } void v3d_session_delete(v3d_session_t *instance) { switch (instance->initialised) { case 1: /* Cancel all our jobs */ <API key>(instance); /* Ensure that any exclusive lock is released */ (void) <API key>(instance->driver, instance); <API key>(instance->driver, instance); case 0: kfree(instance); break; } } void <API key>(v3d_session_t *instance) { instance->start = ktime_get(); instance->total_run = 0; <API key>(&instance->bin_render.queue); <API key>(&instance->bin_render.run); <API key>(&instance->user.queue); <API key>(&instance->user.run); <API key>(&instance->binning_bytes); } void <API key>(v3d_session_t *instance, int user, unsigned int queue, unsigned int run, unsigned int binning_bytes) { instance->total_run += run; if (user != 0) { statistics_add(&instance->user.queue, queue); statistics_add(&instance->user.run, run); statistics_add(&instance->binning_bytes, binning_bytes); } else { statistics_add(&instance->bin_render.queue, queue); statistics_add(&instance->bin_render.run, run); } } int <API key>( v3d_session_t *instance, const v3d_job_post_t *user_job) { return v3d_driver_job_post(instance->driver, instance, user_job); } void remove_job(struct kref *reference) { v3d_driver_job_t *job = container_of(reference, v3d_driver_job_t, waiters); MY_ASSERT(job->session.instance->driver, job != NULL); } void <API key>(struct v3d_driver_job_tag *job, const char *name) { MY_ASSERT(job->session.instance->driver, job != NULL); #ifdef VERBOSE_DEBUG printk(KERN_ERR "%s: j %p %d %s\n", __func__, job, job->waiters.refcount.counter, name); #endif MY_SPINLOCK_CHECK(&job->session.instance->driver->job.issued.lock, 1); kref_get(&job->waiters); /* Prevents freeing on completion */ } void <API key>(struct v3d_driver_job_tag *job, const char *name) { v3d_session_t *instance = job->session.instance; int last; MY_ASSERT(job->session.instance->driver, job != NULL); MY_ASSERT(job->session.instance->driver, job->state != <API key>); MY_SPINLOCK_CHECK(&instance->driver->job.issued.lock, 0); #ifdef VERBOSE_DEBUG printk(KERN_ERR "%s: j %p %d %s\n", __func__, job, job->waiters.refcount.counter, name); #endif last = kref_put(&job->waiters, &remove_job); if (last != 0) { #ifdef VERBOSE_DEBUG printk(KERN_ERR "%s: j %p %s - completing\n", __func__, job, name); #endif <API key>(instance->driver, job); } } void <API key>(v3d_driver_job_t *job) { v3d_session_t *instance = job->session.instance; MY_ASSERT(job->session.instance->driver, job != NULL); MY_SPINLOCK_CHECK(&instance->driver->job.issued.lock, 1); instance->last_id = (int32_t) job->user_job.job_id; job->state = <API key>; list_add_tail(&job->session.link, &instance->issued.list); } void <API key>(v3d_driver_job_t *job, int status) { v3d_session_t *instance; MY_ASSERT(job->session.instance->driver, job != NULL); #ifdef VERBOSE_DEBUG printk(KERN_ERR "%s: j %p s %d:%d\n", __func__, job, job->state, status); #endif instance = job->session.instance; MY_SPINLOCK_CHECK(&instance->driver->job.issued.lock, 1); MY_ASSERT(job->session.instance->driver, job->state == <API key> || status != 0); list_del(&job->session.link); job->state = <API key>; job->status = status; wake_up_all(&job->wait_for_completion); if (instance->performance_counter.enables != 0 && status == 0) <API key>(job->device, &instance->performance_counter.count[0]); } void <API key>(v3d_session_t *instance) { int cancelled = 0; unsigned long flags; /* Wait on all previous jobs, if any - only really required when multiple V3D blocks exist */ v3d_driver_job_t *job; flags = <API key>(instance->driver); while (list_empty(&instance->issued.list) == 0) { job = list_first_entry(&instance->issued.list, v3d_driver_job_t, session.link); cancelled = <API key>(instance->driver, job); if (cancelled != 0) { <API key>(job, -ECANCELED); <API key>(instance->driver, flags); } else { <API key>(job, __func__); <API key>(instance->driver, flags); <API key>(job->device, job, 1); } <API key>(job, __func__); flags = <API key>(instance->driver); } <API key>(instance->driver, flags); } static void wait_job(v3d_session_t *instance, v3d_driver_job_t *job) { int remaining_time; int state; MY_ASSERT(instance->driver, job != NULL); MY_SPINLOCK_CHECK(&instance->driver->job.issued.lock, 0); do { state = job->state; remaining_time = wait_event_timeout(job->wait_for_completion, job->state == <API key>, msecs_to_jiffies(JOB_TIMEOUT_MS)); } while (remaining_time == 0 && state == <API key> && (printk(KERN_ERR "%s: j %p not yet issued, rewaiting\n", __func__, job), 1)); if (remaining_time == 0) { printk(KERN_ERR "V3D job %p timed-out in state %d, active %p", job, job->state, job->device->in_progress.job); debug_dump(instance->driver); <API key>(job->device, job, 1); } } int32_t v3d_session_wait(v3d_session_t *instance) { int32_t id = instance->last_id; unsigned long flags; /* Wait on all previous jobs, if any - only required when multiple V3D blocks exist */ do { v3d_driver_job_t *job = NULL; flags = <API key>(instance->driver); if (list_empty(&instance->issued.list) == 0) job = list_first_entry(&instance->issued.list, v3d_driver_job_t, session.link); if (job == NULL || id - (int32_t) job->user_job.job_id < 0) { <API key>(instance->driver, flags); return id; } <API key>(job, __func__); /* Prevents freeing on completion */ <API key>(instance->driver, flags); wait_job(instance, job); <API key>(job, __func__); /* Remove waiting reference */ } while (1); } int <API key>(v3d_session_t *instance, uint32_t enables) { if (instance->performance_counter.enables != 0) return -1; instance->performance_counter.enables = enables; memset( &instance->performance_counter.count[0], 0, sizeof(instance->performance_counter.count)); <API key>(instance->driver, enables); return 0; } int <API key>(v3d_session_t *instance) { if (instance->performance_counter.enables == 0) return -1; instance->performance_counter.enables = 0; return 0; } const uint32_t *<API key>(v3d_session_t *instance) { return instance->performance_counter.enables == 0 ? &instance->performance_counter.count[0] : NULL; }
global.urlp; module.exports = { 'Step One : Configure nginx-helpers settings from dashboard ': function(browser) { var data = browser.globals; browser .maximizeWindow() .wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD) .nginxSettings() .pause(2000) .getAttribute('#enable_purge', "checked", function(result) { if (result.value) { console.log('check box is already enabled'); } else { browser.click('#enable_purge'); browser.click('#<API key>'); } }) .<API key>() .click('#<API key>') .click('#<API key>') .pause(1000) }, 'step two: Create page & check on frontend test ': function(browser) { var data = browser.globals; browser .goToAddNewPage() .clearValue('#title') .clearValue('textarea[id="content"]') .setValue('#title', 'test-page') .setValue('textarea[id="content"]', "test page created for testing") .pause(1000) .click('#publish') .pause(2000) .getText("#editable-post-name", function(result) { urlp = result.value; console.log(data.URLS.LOGIN + urlp); browser .wplogout() .pause(500) .url(data.URLS.LOGIN + urlp) .assert.containsText("#main", "test page created for testing") }) }, 'Step three : Update Content in Page & check on frontend': function(browser) { var data = browser.globals; browser .wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD) .url(data.URLS.LOGIN + urlp) .click('.post-edit-link') .clearValue('#title') .setValue('#title', "test page title updated") .click('#publish') .pause(2000) .wplogout() .url(data.URLS.LOGIN + urlp) .verify.containsText(".entry-title", "test page title updated") .verify.containsText(".site-main", "test page created for testing") }, 'Step four : Page comment check ': function(browser) { var data = browser.globals; browser .wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD) .url(data.URLS.LOGIN + urlp) .setValue('textarea[name="comment"]', 'this is a demo test comment on page') .click('input[value="Post Comment"]') .assert.containsText("#main", "this is a demo test comment on page") .wplogout() .url(data.URLS.LOGIN + urlp) .assert.containsText("#main", "this is a demo test comment on page") }, 'Step five : Move to trash test ': function(browser) { var data = browser.globals; browser .wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD) .url(data.URLS.LOGIN + urlp) .click('.post-edit-link') .click('xpath', '//a[text()="Move to Trash"]') .pause(2500) .wplogout() .url(data.URLS.LOGIN + urlp); browser.expect.element('#main').text.to.not.contain("this is a demo test comment on page"); browser.end(); } };
#define pr_fmt(fmt) "pinctrl core: " fmt #include <linux/kernel.h> #include <linux/kref.h> #include <linux/export.h> #include <linux/init.h> #include <linux/device.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/list.h> #include <linux/sysfs.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/pinctrl/consumer.h> #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/machine.h> #ifdef CONFIG_GPIOLIB #include <asm-generic/gpio.h> #endif #include "core.h" #include "devicetree.h" #include "pinmux.h" #include "pinconf.h" static bool pinctrl_dummy_state; /* Mutex taken to protect pinctrl_list */ static DEFINE_MUTEX(pinctrl_list_mutex); /* Mutex taken to protect pinctrl_maps */ DEFINE_MUTEX(pinctrl_maps_mutex); /* Mutex taken to protect pinctrldev_list */ static DEFINE_MUTEX(<API key>); /* Global list of pin control devices (struct pinctrl_dev) */ static LIST_HEAD(pinctrldev_list); /* List of pin controller handles (struct pinctrl) */ static LIST_HEAD(pinctrl_list); /* List of pinctrl maps (struct pinctrl_maps) */ LIST_HEAD(pinctrl_maps); /** * <API key>() - indicate if pinctrl provides dummy state support * * Usually this function is called by platforms without pinctrl driver support * but run with some shared drivers using pinctrl APIs. * After calling this function, the pinctrl core will return successfully * with creating a dummy state for the driver to keep going smoothly. */ void <API key>(void) { pinctrl_dummy_state = true; } const char *<API key>(struct pinctrl_dev *pctldev) { /* We're not allowed to register devices without name */ return pctldev->desc->name; } EXPORT_SYMBOL_GPL(<API key>); const char *<API key>(struct pinctrl_dev *pctldev) { return dev_name(pctldev->dev); } EXPORT_SYMBOL_GPL(<API key>); void *<API key>(struct pinctrl_dev *pctldev) { return pctldev->driver_data; } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - look up pin controller device * @devname: the name of a device instance, as returned by dev_name() * * Looks up a pin control device matching a certain device name or pure device * pointer, the pure device pointer will take precedence. */ struct pinctrl_dev *<API key>(const char *devname) { struct pinctrl_dev *pctldev = NULL; if (!devname) return NULL; mutex_lock(&<API key>); list_for_each_entry(pctldev, &pinctrldev_list, node) { if (!strcmp(dev_name(pctldev->dev), devname)) { /* Matched on device name */ mutex_unlock(&<API key>); return pctldev; } } mutex_unlock(&<API key>); return NULL; } struct pinctrl_dev *<API key>(struct device_node *np) { struct pinctrl_dev *pctldev; mutex_lock(&<API key>); list_for_each_entry(pctldev, &pinctrldev_list, node) if (pctldev->dev->of_node == np) { mutex_unlock(&<API key>); return pctldev; } mutex_unlock(&<API key>); return NULL; } EXPORT_SYMBOL_GPL(<API key>); /** * pin_get_from_name() - look up a pin number from a name * @pctldev: the pin control device to lookup the pin on * @name: the name of the pin to look up */ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name) { unsigned i, pin; /* The pin number can be retrived from the pin controller descriptor */ for (i = 0; i < pctldev->desc->npins; i++) { struct pin_desc *desc; pin = pctldev->desc->pins[i].number; desc = pin_desc_get(pctldev, pin); /* Pin space may be sparse */ if (desc && !strcmp(name, desc->name)) return pin; } return -EINVAL; } /** * <API key>() - look up a pin name from a pin id * @pctldev: the pin control device to lookup the pin on * @name: the name of the pin to look up */ const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin) { const struct pin_desc *desc; desc = pin_desc_get(pctldev, pin); if (desc == NULL) { dev_err(pctldev->dev, "failed to get pin(%d) name\n", pin); return NULL; } return desc->name; } /** * pin_is_valid() - check if pin exists on controller * @pctldev: the pin control device to check the pin on * @pin: pin to check, use the local pin controller index number * * This tells us whether a certain pin exist on a certain pin controller or * not. Pin lists may be sparse, so some pins may not exist. */ bool pin_is_valid(struct pinctrl_dev *pctldev, int pin) { struct pin_desc *pindesc; if (pin < 0) return false; mutex_lock(&pctldev->mutex); pindesc = pin_desc_get(pctldev, pin); mutex_unlock(&pctldev->mutex); return pindesc != NULL; } EXPORT_SYMBOL_GPL(pin_is_valid); /* Deletes a range of pin descriptors */ static void <API key>(struct pinctrl_dev *pctldev, const struct pinctrl_pin_desc *pins, unsigned num_pins) { int i; for (i = 0; i < num_pins; i++) { struct pin_desc *pindesc; pindesc = radix_tree_lookup(&pctldev->pin_desc_tree, pins[i].number); if (pindesc != NULL) { radix_tree_delete(&pctldev->pin_desc_tree, pins[i].number); if (pindesc->dynamic_name) kfree(pindesc->name); } kfree(pindesc); } } static int <API key>(struct pinctrl_dev *pctldev, unsigned number, const char *name) { struct pin_desc *pindesc; pindesc = pin_desc_get(pctldev, number); if (pindesc != NULL) { pr_err("pin %d already registered on %s\n", number, pctldev->desc->name); return -EINVAL; } pindesc = kzalloc(sizeof(*pindesc), GFP_KERNEL); if (pindesc == NULL) { dev_err(pctldev->dev, "failed to alloc struct pin_desc\n"); return -ENOMEM; } /* Set owner */ pindesc->pctldev = pctldev; /* Copy basic pin info */ if (name) { pindesc->name = name; } else { pindesc->name = kasprintf(GFP_KERNEL, "PIN%u", number); if (pindesc->name == NULL) { kfree(pindesc); return -ENOMEM; } pindesc->dynamic_name = true; } radix_tree_insert(&pctldev->pin_desc_tree, number, pindesc); pr_debug("registered pin %d (%s) on %s\n", number, pindesc->name, pctldev->desc->name); return 0; } static int <API key>(struct pinctrl_dev *pctldev, struct pinctrl_pin_desc const *pins, unsigned num_descs) { unsigned i; int ret = 0; for (i = 0; i < num_descs; i++) { ret = <API key>(pctldev, pins[i].number, pins[i].name); if (ret) return ret; } return 0; } /** * gpio_to_pin() - GPIO range GPIO number to pin number translation * @range: GPIO range used for the translation * @gpio: gpio pin to translate to a pin number * * Finds the pin number for a given GPIO using the specified GPIO range * as a base for translation. The distinction between linear GPIO ranges * and pin list based GPIO ranges is managed correctly by this function. * * This function assumes the gpio is part of the specified GPIO range, use * only after making sure this is the case (e.g. by calling it on the * result of successful <API key> calls)! */ static inline int gpio_to_pin(struct pinctrl_gpio_range *range, unsigned int gpio) { unsigned int offset = gpio - range->base; if (range->pins) return range->pins[offset]; else return range->pin_base + offset; } /** * <API key>() - check if a certain GPIO pin is in range * @pctldev: pin controller device to check * @gpio: gpio pin to check taken from the global GPIO pin space * * Tries to match a GPIO pin number to the ranges handled by a certain pin * controller, return the range or NULL */ static struct pinctrl_gpio_range * <API key>(struct pinctrl_dev *pctldev, unsigned gpio) { struct pinctrl_gpio_range *range = NULL; mutex_lock(&pctldev->mutex); /* Loop over the ranges */ list_for_each_entry(range, &pctldev->gpio_ranges, node) { /* Check if we're in the valid range */ if (gpio >= range->base && gpio < range->base + range->npins) { mutex_unlock(&pctldev->mutex); return range; } } mutex_unlock(&pctldev->mutex); return NULL; } /** * <API key>() - check if other GPIO pins of * the same GPIO chip are in range * @gpio: gpio pin to check taken from the global GPIO pin space * * This function is complement of <API key>(). If the return * value of <API key>() is NULL, this function could be used * to check whether pinctrl device is ready or not. Maybe some GPIO pins * of the same GPIO chip don't have back-end pinctrl interface. * If the return value is true, it means that pinctrl device is ready & the * certain GPIO pin doesn't have back-end pinctrl device. If the return value * is false, it means that pinctrl device may not be ready. */ #ifdef CONFIG_GPIOLIB static bool <API key>(unsigned gpio) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range = NULL; struct gpio_chip *chip = gpio_to_chip(gpio); mutex_lock(&<API key>); /* Loop over the pin controllers */ list_for_each_entry(pctldev, &pinctrldev_list, node) { /* Loop over the ranges */ mutex_lock(&pctldev->mutex); list_for_each_entry(range, &pctldev->gpio_ranges, node) { /* Check if any gpio range overlapped with gpio chip */ if (range->base + range->npins - 1 < chip->base || range->base > chip->base + chip->ngpio - 1) continue; mutex_unlock(&pctldev->mutex); mutex_unlock(&<API key>); return true; } mutex_unlock(&pctldev->mutex); } mutex_unlock(&<API key>); return false; } #else static bool <API key>(unsigned gpio) { return true; } #endif /** * <API key>() - find device for GPIO range * @gpio: the pin to locate the pin controller for * @outdev: the pin control device if found * @outrange: the GPIO range if found * * Find the pin controller handling a certain GPIO pin from the pinspace of * the GPIO subsystem, return the device and the matching GPIO range. Returns * -EPROBE_DEFER if the GPIO range could not be found in any device since it * may still have not been registered. */ static int <API key>(unsigned gpio, struct pinctrl_dev **outdev, struct pinctrl_gpio_range **outrange) { struct pinctrl_dev *pctldev = NULL; mutex_lock(&<API key>); /* Loop over the pin controllers */ list_for_each_entry(pctldev, &pinctrldev_list, node) { struct pinctrl_gpio_range *range; range = <API key>(pctldev, gpio); if (range != NULL) { *outdev = pctldev; *outrange = range; mutex_unlock(&<API key>); return 0; } } mutex_unlock(&<API key>); return -EPROBE_DEFER; } /** * <API key>() - register a GPIO range for a controller * @pctldev: pin controller device to add the range to * @range: the GPIO range to add * * This adds a range of GPIOs to be handled by a certain pin controller. Call * this to register handled ranges after registering your pin controller. */ void <API key>(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range) { mutex_lock(&pctldev->mutex); list_add_tail(&range->node, &pctldev->gpio_ranges); mutex_unlock(&pctldev->mutex); } EXPORT_SYMBOL_GPL(<API key>); void <API key>(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *ranges, unsigned nranges) { int i; for (i = 0; i < nranges; i++) <API key>(pctldev, &ranges[i]); } EXPORT_SYMBOL_GPL(<API key>); struct pinctrl_dev *<API key>(const char *devname, struct pinctrl_gpio_range *range) { struct pinctrl_dev *pctldev; pctldev = <API key>(devname); /* * If we can't find this device, let's assume that is because * it has not probed yet, so the driver trying to register this * range need to defer probing. */ if (!pctldev) { return ERR_PTR(-EPROBE_DEFER); } <API key>(pctldev, range); return pctldev; } EXPORT_SYMBOL_GPL(<API key>); int <API key>(struct pinctrl_dev *pctldev, const char *pin_group, const unsigned **pins, unsigned *num_pins) { const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; int gs; gs = <API key>(pctldev, pin_group); if (gs < 0) return gs; return pctlops->get_group_pins(pctldev, gs, pins, num_pins); } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - locate the GPIO range for a pin * @pctldev: the pin controller device to look in * @pin: a controller-local number to find the range for */ struct pinctrl_gpio_range * <API key>(struct pinctrl_dev *pctldev, unsigned int pin) { struct pinctrl_gpio_range *range; mutex_lock(&pctldev->mutex); /* Loop over the ranges */ list_for_each_entry(range, &pctldev->gpio_ranges, node) { /* Check if we're in the valid range */ if (range->pins) { int a; for (a = 0; a < range->npins; a++) { if (range->pins[a] == pin) goto out; } } else if (pin >= range->pin_base && pin < range->pin_base + range->npins) goto out; } range = NULL; out: mutex_unlock(&pctldev->mutex); return range; } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - remove a range of GPIOs fro a pin controller * @pctldev: pin controller device to remove the range from * @range: the GPIO range to remove */ void <API key>(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range) { mutex_lock(&pctldev->mutex); list_del(&range->node); mutex_unlock(&pctldev->mutex); } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - returns the group selector for a group * @pctldev: the pin controller handling the group * @pin_group: the pin group to look up */ int <API key>(struct pinctrl_dev *pctldev, const char *pin_group) { const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; unsigned ngroups = pctlops->get_groups_count(pctldev); unsigned group_selector = 0; while (group_selector < ngroups) { const char *gname = pctlops->get_group_name(pctldev, group_selector); if (!strcmp(gname, pin_group)) { dev_dbg(pctldev->dev, "found group selector %u for %s\n", group_selector, pin_group); return group_selector; } group_selector++; } dev_err(pctldev->dev, "does not have pin group %s\n", pin_group); return -EINVAL; } /** * <API key>() - request a single pin to be used in as GPIO * @gpio: the GPIO pin number from the GPIO subsystem number space * * This function should *ONLY* be used from gpiolib-based GPIO drivers, * as part of their gpio_request() semantics, platforms and individual drivers * shall *NOT* request GPIO pins to be muxed in. */ int <API key>(unsigned gpio) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range; int ret; int pin; ret = <API key>(gpio, &pctldev, &range); if (ret) { if (<API key>(gpio)) ret = 0; return ret; } mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ pin = gpio_to_pin(range, gpio); ret = pinmux_request_gpio(pctldev, range, pin, gpio); mutex_unlock(&pctldev->mutex); return ret; } EXPORT_SYMBOL_GPL(<API key>); /** * pinctrl_free_gpio() - free control on a single pin, currently used as GPIO * @gpio: the GPIO pin number from the GPIO subsystem number space * * This function should *ONLY* be used from gpiolib-based GPIO drivers, * as part of their gpio_free() semantics, platforms and individual drivers * shall *NOT* request GPIO pins to be muxed out. */ void pinctrl_free_gpio(unsigned gpio) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range; int ret; int pin; ret = <API key>(gpio, &pctldev, &range); if (ret) { return; } mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ pin = gpio_to_pin(range, gpio); pinmux_free_gpio(pctldev, pin, range); mutex_unlock(&pctldev->mutex); } EXPORT_SYMBOL_GPL(pinctrl_free_gpio); static int <API key>(unsigned gpio, bool input) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range; int ret; int pin; ret = <API key>(gpio, &pctldev, &range); if (ret) { return ret; } mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ pin = gpio_to_pin(range, gpio); ret = <API key>(pctldev, range, pin, input); mutex_unlock(&pctldev->mutex); return ret; } /** * <API key>() - request a GPIO pin to go into input mode * @gpio: the GPIO pin number from the GPIO subsystem number space * * This function should *ONLY* be used from gpiolib-based GPIO drivers, * as part of their <API key>() semantics, platforms and individual * drivers shall *NOT* touch pin control GPIO calls. */ int <API key>(unsigned gpio) { return <API key>(gpio, true); } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - request a GPIO pin to go into output mode * @gpio: the GPIO pin number from the GPIO subsystem number space * * This function should *ONLY* be used from gpiolib-based GPIO drivers, * as part of their <API key>() semantics, platforms and individual * drivers shall *NOT* touch pin control GPIO calls. */ int <API key>(unsigned gpio) { return <API key>(gpio, false); } EXPORT_SYMBOL_GPL(<API key>); static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { struct pinctrl_state *state; list_for_each_entry(state, &p->states, node) if (!strcmp(state->name, name)) return state; return NULL; } static struct pinctrl_state *create_state(struct pinctrl *p, const char *name) { struct pinctrl_state *state; state = kzalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) { dev_err(p->dev, "failed to alloc struct pinctrl_state\n"); return ERR_PTR(-ENOMEM); } state->name = name; INIT_LIST_HEAD(&state->settings); list_add_tail(&state->node, &p->states); return state; } static int add_setting(struct pinctrl *p, struct pinctrl_map const *map) { struct pinctrl_state *state; struct pinctrl_setting *setting; int ret; state = find_state(p, map->name); if (!state) state = create_state(p, map->name); if (IS_ERR(state)) return PTR_ERR(state); if (map->type == <API key>) return 0; setting = kzalloc(sizeof(*setting), GFP_KERNEL); if (setting == NULL) { dev_err(p->dev, "failed to alloc struct pinctrl_setting\n"); return -ENOMEM; } setting->type = map->type; setting->pctldev = <API key>(map->ctrl_dev_name); if (setting->pctldev == NULL) { kfree(setting); /* Do not defer probing of hogs (circular loop) */ if (!strcmp(map->ctrl_dev_name, map->dev_name)) return -ENODEV; /* * OK let us guess that the driver is not there yet, and * let's defer obtaining this pinctrl handle to later... */ dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe", map->ctrl_dev_name); return -EPROBE_DEFER; } setting->dev_name = map->dev_name; switch (map->type) { case <API key>: ret = <API key>(map, setting); break; case <API key>: case <API key>: ret = <API key>(map, setting); break; default: ret = -EINVAL; break; } if (ret < 0) { kfree(setting); return ret; } list_add_tail(&setting->node, &state->settings); return 0; } static struct pinctrl *find_pinctrl(struct device *dev) { struct pinctrl *p; mutex_lock(&pinctrl_list_mutex); list_for_each_entry(p, &pinctrl_list, node) if (p->dev == dev) { mutex_unlock(&pinctrl_list_mutex); return p; } mutex_unlock(&pinctrl_list_mutex); return NULL; } static void pinctrl_free(struct pinctrl *p, bool inlist); static struct pinctrl *create_pinctrl(struct device *dev) { struct pinctrl *p; const char *devname; struct pinctrl_maps *maps_node; int i; struct pinctrl_map const *map; int ret; /* * create the state cookie holder struct pinctrl for each * mapping, this is what consumers will get when requesting * a pin control handle with pinctrl_get() */ p = kzalloc(sizeof(*p), GFP_KERNEL); if (p == NULL) { dev_err(dev, "failed to alloc struct pinctrl\n"); return ERR_PTR(-ENOMEM); } p->dev = dev; INIT_LIST_HEAD(&p->states); INIT_LIST_HEAD(&p->dt_maps); ret = pinctrl_dt_to_map(p); if (ret < 0) { kfree(p); return ERR_PTR(ret); } devname = dev_name(dev); mutex_lock(&pinctrl_maps_mutex); /* Iterate over the pin control maps to locate the right ones */ for_each_maps(maps_node, i, map) { /* Map must be for this device */ if (strcmp(map->dev_name, devname)) continue; ret = add_setting(p, map); /* * At this point the adding of a setting may: * * - Defer, if the pinctrl device is not yet available * - Fail, if the pinctrl device is not yet available, * AND the setting is a hog. We cannot defer that, since * the hog will kick in immediately after the device * is registered. * * If the error returned was not -EPROBE_DEFER then we * accumulate the errors to see if we end up with * an -EPROBE_DEFER later, as that is the worst case. */ if (ret == -EPROBE_DEFER) { pinctrl_free(p, false); mutex_unlock(&pinctrl_maps_mutex); return ERR_PTR(ret); } } mutex_unlock(&pinctrl_maps_mutex); if (ret < 0) { /* If some other error than deferral occured, return here */ pinctrl_free(p, false); return ERR_PTR(ret); } kref_init(&p->users); /* Add the pinctrl handle to the global list */ mutex_lock(&pinctrl_list_mutex); list_add_tail(&p->node, &pinctrl_list); mutex_unlock(&pinctrl_list_mutex); return p; } /** * pinctrl_get() - retrieves the pinctrl handle for a device * @dev: the device to obtain the handle for */ struct pinctrl *pinctrl_get(struct device *dev) { struct pinctrl *p; if (WARN_ON(!dev)) return ERR_PTR(-EINVAL); /* * See if somebody else (such as the device core) has already * obtained a handle to the pinctrl for this device. In that case, * return another pointer to it. */ p = find_pinctrl(dev); if (p != NULL) { dev_dbg(dev, "obtain a copy of previously claimed pinctrl\n"); kref_get(&p->users); return p; } return create_pinctrl(dev); } EXPORT_SYMBOL_GPL(pinctrl_get); static void <API key>(bool disable_setting, struct pinctrl_setting *setting) { switch (setting->type) { case <API key>: if (disable_setting) <API key>(setting); pinmux_free_setting(setting); break; case <API key>: case <API key>: <API key>(setting); break; default: break; } } static void pinctrl_free(struct pinctrl *p, bool inlist) { struct pinctrl_state *state, *n1; struct pinctrl_setting *setting, *n2; mutex_lock(&pinctrl_list_mutex); <API key>(state, n1, &p->states, node) { <API key>(setting, n2, &state->settings, node) { <API key>(state == p->state, setting); list_del(&setting->node); kfree(setting); } list_del(&state->node); kfree(state); } <API key>(p); if (inlist) list_del(&p->node); kfree(p); mutex_unlock(&pinctrl_list_mutex); } /** * pinctrl_release() - release the pinctrl handle * @kref: the kref in the pinctrl being released */ static void pinctrl_release(struct kref *kref) { struct pinctrl *p = container_of(kref, struct pinctrl, users); pinctrl_free(p, true); } /** * pinctrl_put() - decrease use count on a previously claimed pinctrl handle * @p: the pinctrl handle to release */ void pinctrl_put(struct pinctrl *p) { kref_put(&p->users, pinctrl_release); } EXPORT_SYMBOL_GPL(pinctrl_put); /** * <API key>() - retrieves a state handle from a pinctrl handle * @p: the pinctrl handle to retrieve the state from * @name: the state name to retrieve */ struct pinctrl_state *<API key>(struct pinctrl *p, const char *name) { struct pinctrl_state *state; state = find_state(p, name); if (!state) { if (pinctrl_dummy_state) { /* create dummy state */ dev_dbg(p->dev, "using pinctrl dummy state (%s)\n", name); state = create_state(p, name); } else state = ERR_PTR(-ENODEV); } return state; } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - select/activate/program a pinctrl state to HW * @p: the pinctrl handle for the device that requests configuration * @state: the state handle to select/activate/program */ int <API key>(struct pinctrl *p, struct pinctrl_state *state) { struct pinctrl_setting *setting, *setting2; struct pinctrl_state *old_state = p->state; int ret; if (p->state == state) return 0; if (p->state) { /* * The set of groups with a mux configuration in the old state * may not be identical to the set of groups with a mux setting * in the new state. While this might be unusual, it's entirely * possible for the "user"-supplied mapping table to be written * that way. For each group that was configured in the old state * but not in the new state, this code puts that group into a * safe/disabled state. */ list_for_each_entry(setting, &p->state->settings, node) { bool found = false; if (setting->type != <API key>) continue; list_for_each_entry(setting2, &state->settings, node) { if (setting2->type != <API key>) continue; if (setting2->data.mux.group == setting->data.mux.group) { found = true; break; } } if (!found) <API key>(setting); } } p->state = NULL; /* Apply all the settings for the new state */ list_for_each_entry(setting, &state->settings, node) { switch (setting->type) { case <API key>: ret = <API key>(setting); break; case <API key>: case <API key>: ret = <API key>(setting); break; default: ret = -EINVAL; break; } if (ret < 0) { goto unapply_new_state; } } p->state = state; return 0; unapply_new_state: dev_err(p->dev, "Error applying setting, reverse things back\n"); list_for_each_entry(setting2, &state->settings, node) { if (&setting2->node == &setting->node) break; /* * All we can do here is <API key>. * That means that some pins are muxed differently now * than they were before applying the setting (We can't * "unmux a pin"!), but it's not a big deal since the pins * are free to be muxed by another apply_setting. */ if (setting2->type == <API key>) <API key>(setting2); } /* There's no infinite recursive loop here because p->state is NULL */ if (old_state) <API key>(p, old_state); return ret; } EXPORT_SYMBOL_GPL(<API key>); static void <API key>(struct device *dev, void *res) { pinctrl_put(*(struct pinctrl **)res); } /** * struct devm_pinctrl_get() - Resource managed pinctrl_get() * @dev: the device to obtain the handle for * * If there is a need to explicitly destroy the returned struct pinctrl, * devm_pinctrl_put() should be used, rather than plain pinctrl_put(). */ struct pinctrl *devm_pinctrl_get(struct device *dev) { struct pinctrl **ptr, *p; ptr = devres_alloc(<API key>, sizeof(*ptr), GFP_KERNEL); if (!ptr) return ERR_PTR(-ENOMEM); p = pinctrl_get(dev); if (!IS_ERR(p)) { *ptr = p; devres_add(dev, ptr); } else { devres_free(ptr); } return p; } EXPORT_SYMBOL_GPL(devm_pinctrl_get); static int devm_pinctrl_match(struct device *dev, void *res, void *data) { struct pinctrl **p = res; return *p == data; } /** * devm_pinctrl_put() - Resource managed pinctrl_put() * @p: the pinctrl handle to release * * Deallocate a struct pinctrl obtained via devm_pinctrl_get(). Normally * this function will not need to be called and the resource management * code will ensure that the resource is freed. */ void devm_pinctrl_put(struct pinctrl *p) { WARN_ON(devres_release(p->dev, <API key>, devm_pinctrl_match, p)); } EXPORT_SYMBOL_GPL(devm_pinctrl_put); int <API key>(struct pinctrl_map const *maps, unsigned num_maps, bool dup, bool locked) { int i, ret; struct pinctrl_maps *maps_node; pr_debug("add %d pinmux maps\n", num_maps); /* First sanity check the new mapping */ for (i = 0; i < num_maps; i++) { if (!maps[i].dev_name) { pr_err("failed to register map %s (%d): no device given\n", maps[i].name, i); return -EINVAL; } if (!maps[i].name) { pr_err("failed to register map %d: no map name given\n", i); return -EINVAL; } if (maps[i].type != <API key> && !maps[i].ctrl_dev_name) { pr_err("failed to register map %s (%d): no pin control device given\n", maps[i].name, i); return -EINVAL; } switch (maps[i].type) { case <API key>: break; case <API key>: ret = pinmux_validate_map(&maps[i], i); if (ret < 0) return ret; break; case <API key>: case <API key>: ret = <API key>(&maps[i], i); if (ret < 0) return ret; break; default: pr_err("failed to register map %s (%d): invalid type given\n", maps[i].name, i); return -EINVAL; } } maps_node = kzalloc(sizeof(*maps_node), GFP_KERNEL); if (!maps_node) { pr_err("failed to alloc struct pinctrl_maps\n"); return -ENOMEM; } maps_node->num_maps = num_maps; if (dup) { maps_node->maps = kmemdup(maps, sizeof(*maps) * num_maps, GFP_KERNEL); if (!maps_node->maps) { pr_err("failed to duplicate mapping table\n"); kfree(maps_node); return -ENOMEM; } } else { maps_node->maps = maps; } if (!locked) mutex_lock(&pinctrl_maps_mutex); list_add_tail(&maps_node->node, &pinctrl_maps); if (!locked) mutex_unlock(&pinctrl_maps_mutex); return 0; } /** * <API key>() - register a set of pin controller mappings * @maps: the pincontrol mappings table to register. This should probably be * marked with __initdata so it can be discarded after boot. This * function will perform a shallow copy for the mapping entries. * @num_maps: the number of maps in the mapping table */ int <API key>(struct pinctrl_map const *maps, unsigned num_maps) { return <API key>(maps, num_maps, true, false); } void <API key>(struct pinctrl_map const *map) { struct pinctrl_maps *maps_node; mutex_lock(&pinctrl_maps_mutex); list_for_each_entry(maps_node, &pinctrl_maps, node) { if (maps_node->maps == map) { list_del(&maps_node->node); kfree(maps_node); mutex_unlock(&pinctrl_maps_mutex); return; } } mutex_unlock(&pinctrl_maps_mutex); } /** * pinctrl_force_sleep() - turn a given controller device into sleep state * @pctldev: pin controller device */ int pinctrl_force_sleep(struct pinctrl_dev *pctldev) { if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_sleep)) return <API key>(pctldev->p, pctldev->hog_sleep); return 0; } EXPORT_SYMBOL_GPL(pinctrl_force_sleep); /** * <API key>() - turn a given controller device into default state * @pctldev: pin controller device */ int <API key>(struct pinctrl_dev *pctldev) { if (!IS_ERR(pctldev->p) && !IS_ERR(pctldev->hog_default)) return <API key>(pctldev->p, pctldev->hog_default); return 0; } EXPORT_SYMBOL_GPL(<API key>); #ifdef CONFIG_PM /** * <API key>() - select pinctrl state for PM * @dev: device to select default state for * @state: state to set */ static int <API key>(struct device *dev, struct pinctrl_state *state) { struct dev_pin_info *pins = dev->pins; int ret; if (IS_ERR(state)) return 0; /* No such state */ ret = <API key>(pins->p, state); if (ret) dev_err(dev, "failed to activate pinctrl state %s\n", state->name); return ret; } /** * <API key>() - select default pinctrl state for PM * @dev: device to select default state for */ int <API key>(struct device *dev) { if (!dev->pins) return 0; return <API key>(dev, dev->pins->default_state); } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - select sleep pinctrl state for PM * @dev: device to select sleep state for */ int <API key>(struct device *dev) { if (!dev->pins) return 0; return <API key>(dev, dev->pins->sleep_state); } EXPORT_SYMBOL_GPL(<API key>); /** * <API key>() - select idle pinctrl state for PM * @dev: device to select idle state for */ int <API key>(struct device *dev) { if (!dev->pins) return 0; return <API key>(dev, dev->pins->idle_state); } EXPORT_SYMBOL_GPL(<API key>); #endif #ifdef CONFIG_DEBUG_FS static int pinctrl_pins_show(struct seq_file *s, void *what) { struct pinctrl_dev *pctldev = s->private; const struct pinctrl_ops *ops = pctldev->desc->pctlops; unsigned i, pin; seq_printf(s, "registered pins: %d\n", pctldev->desc->npins); mutex_lock(&pctldev->mutex); /* The pin number can be retrived from the pin controller descriptor */ for (i = 0; i < pctldev->desc->npins; i++) { struct pin_desc *desc; pin = pctldev->desc->pins[i].number; desc = pin_desc_get(pctldev, pin); /* Pin space may be sparse */ if (desc == NULL) continue; seq_printf(s, "pin %d (%s) ", pin, desc->name ? desc->name : "unnamed"); /* Driver-specific info per pin */ if (ops->pin_dbg_show) ops->pin_dbg_show(pctldev, s, pin); seq_puts(s, "\n"); } mutex_unlock(&pctldev->mutex); return 0; } static int pinctrl_groups_show(struct seq_file *s, void *what) { struct pinctrl_dev *pctldev = s->private; const struct pinctrl_ops *ops = pctldev->desc->pctlops; unsigned ngroups, selector = 0; mutex_lock(&pctldev->mutex); ngroups = ops->get_groups_count(pctldev); seq_puts(s, "registered pin groups:\n"); while (selector < ngroups) { const unsigned *pins; unsigned num_pins; const char *gname = ops->get_group_name(pctldev, selector); const char *pname; int ret; int i; ret = ops->get_group_pins(pctldev, selector, &pins, &num_pins); if (ret) seq_printf(s, "%s [ERROR GETTING PINS]\n", gname); else { seq_printf(s, "group: %s\n", gname); for (i = 0; i < num_pins; i++) { pname = pin_get_name(pctldev, pins[i]); if (WARN_ON(!pname)) { mutex_unlock(&pctldev->mutex); return -EINVAL; } seq_printf(s, "pin %d (%s)\n", pins[i], pname); } seq_puts(s, "\n"); } selector++; } mutex_unlock(&pctldev->mutex); return 0; } static int <API key>(struct seq_file *s, void *what) { struct pinctrl_dev *pctldev = s->private; struct pinctrl_gpio_range *range = NULL; seq_puts(s, "GPIO ranges handled:\n"); mutex_lock(&pctldev->mutex); /* Loop over the ranges */ list_for_each_entry(range, &pctldev->gpio_ranges, node) { if (range->pins) { int a; seq_printf(s, "%u: %s GPIOS [%u - %u] PINS {", range->id, range->name, range->base, (range->base + range->npins - 1)); for (a = 0; a < range->npins - 1; a++) seq_printf(s, "%u, ", range->pins[a]); seq_printf(s, "%u}\n", range->pins[a]); } else seq_printf(s, "%u: %s GPIOS [%u - %u] PINS [%u - %u]\n", range->id, range->name, range->base, (range->base + range->npins - 1), range->pin_base, (range->pin_base + range->npins - 1)); } mutex_unlock(&pctldev->mutex); return 0; } static int <API key>(struct seq_file *s, void *what) { struct pinctrl_dev *pctldev; seq_puts(s, "name [pinmux] [pinconf]\n"); mutex_lock(&<API key>); list_for_each_entry(pctldev, &pinctrldev_list, node) { seq_printf(s, "%s ", pctldev->desc->name); if (pctldev->desc->pmxops) seq_puts(s, "yes "); else seq_puts(s, "no "); if (pctldev->desc->confops) seq_puts(s, "yes"); else seq_puts(s, "no"); seq_puts(s, "\n"); } mutex_unlock(&<API key>); return 0; } static inline const char *map_type(enum pinctrl_map_type type) { static const char * const names[] = { "INVALID", "DUMMY_STATE", "MUX_GROUP", "CONFIGS_PIN", "CONFIGS_GROUP", }; if (type >= ARRAY_SIZE(names)) return "UNKNOWN"; return names[type]; } static int pinctrl_maps_show(struct seq_file *s, void *what) { struct pinctrl_maps *maps_node; int i; struct pinctrl_map const *map; seq_puts(s, "Pinctrl maps:\n"); mutex_lock(&pinctrl_maps_mutex); for_each_maps(maps_node, i, map) { seq_printf(s, "device %s\nstate %s\ntype %s (%d)\n", map->dev_name, map->name, map_type(map->type), map->type); if (map->type != <API key>) seq_printf(s, "controlling device %s\n", map->ctrl_dev_name); switch (map->type) { case <API key>: pinmux_show_map(s, map); break; case <API key>: case <API key>: pinconf_show_map(s, map); break; default: break; } seq_printf(s, "\n"); } mutex_unlock(&pinctrl_maps_mutex); return 0; } static int pinctrl_show(struct seq_file *s, void *what) { struct pinctrl *p; struct pinctrl_state *state; struct pinctrl_setting *setting; seq_puts(s, "Requested pin control handlers their pinmux maps:\n"); mutex_lock(&pinctrl_list_mutex); list_for_each_entry(p, &pinctrl_list, node) { seq_printf(s, "device: %s current state: %s\n", dev_name(p->dev), p->state ? p->state->name : "none"); list_for_each_entry(state, &p->states, node) { seq_printf(s, " state: %s\n", state->name); list_for_each_entry(setting, &state->settings, node) { struct pinctrl_dev *pctldev = setting->pctldev; seq_printf(s, " type: %s controller %s ", map_type(setting->type), <API key>(pctldev)); switch (setting->type) { case <API key>: pinmux_show_setting(s, setting); break; case <API key>: case <API key>: <API key>(s, setting); break; default: break; } } } } mutex_unlock(&pinctrl_list_mutex); return 0; } static int pinctrl_pins_open(struct inode *inode, struct file *file) { return single_open(file, pinctrl_pins_show, inode->i_private); } static int pinctrl_groups_open(struct inode *inode, struct file *file) { return single_open(file, pinctrl_groups_show, inode->i_private); } static int <API key>(struct inode *inode, struct file *file) { return single_open(file, <API key>, inode->i_private); } static int <API key>(struct inode *inode, struct file *file) { return single_open(file, <API key>, NULL); } static int pinctrl_maps_open(struct inode *inode, struct file *file) { return single_open(file, pinctrl_maps_show, NULL); } static int pinctrl_open(struct inode *inode, struct file *file) { return single_open(file, pinctrl_show, NULL); } static const struct file_operations pinctrl_pins_ops = { .open = pinctrl_pins_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static const struct file_operations pinctrl_groups_ops = { .open = pinctrl_groups_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static const struct file_operations <API key> = { .open = <API key>, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static const struct file_operations pinctrl_devices_ops = { .open = <API key>, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static const struct file_operations pinctrl_maps_ops = { .open = pinctrl_maps_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static const struct file_operations pinctrl_ops = { .open = pinctrl_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static struct dentry *debugfs_root; static void <API key>(struct pinctrl_dev *pctldev) { struct dentry *device_root; device_root = debugfs_create_dir(dev_name(pctldev->dev), debugfs_root); pctldev->device_root = device_root; if (IS_ERR(device_root) || !device_root) { pr_warn("failed to create debugfs directory for %s\n", dev_name(pctldev->dev)); return; } debugfs_create_file("pins", S_IFREG | S_IRUGO, device_root, pctldev, &pinctrl_pins_ops); debugfs_create_file("pingroups", S_IFREG | S_IRUGO, device_root, pctldev, &pinctrl_groups_ops); debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO, device_root, pctldev, &<API key>); if (pctldev->desc->pmxops) <API key>(device_root, pctldev); if (pctldev->desc->confops) <API key>(device_root, pctldev); } static void <API key>(struct pinctrl_dev *pctldev) { <API key>(pctldev->device_root); } static void <API key>(void) { debugfs_root = debugfs_create_dir("pinctrl", NULL); if (IS_ERR(debugfs_root) || !debugfs_root) { pr_warn("failed to create debugfs directory\n"); debugfs_root = NULL; return; } debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, debugfs_root, NULL, &pinctrl_devices_ops); debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO, debugfs_root, NULL, &pinctrl_maps_ops); debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO, debugfs_root, NULL, &pinctrl_ops); } #else /* CONFIG_DEBUG_FS */ static void <API key>(struct pinctrl_dev *pctldev) { } static void <API key>(void) { } static void <API key>(struct pinctrl_dev *pctldev) { } #endif static int pinctrl_check_ops(struct pinctrl_dev *pctldev) { const struct pinctrl_ops *ops = pctldev->desc->pctlops; if (!ops || !ops->get_groups_count || !ops->get_group_name || !ops->get_group_pins) return -EINVAL; if (ops->dt_node_to_map && !ops->dt_free_map) return -EINVAL; return 0; } /** * pinctrl_register() - register a pin controller device * @pctldesc: descriptor for this pin controller * @dev: parent device for this pin controller * @driver_data: private pin controller data for this pin controller */ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, struct device *dev, void *driver_data) { struct pinctrl_dev *pctldev; int ret; if (!pctldesc) return NULL; if (!pctldesc->name) return NULL; pctldev = kzalloc(sizeof(*pctldev), GFP_KERNEL); if (pctldev == NULL) { dev_err(dev, "failed to alloc struct pinctrl_dev\n"); return NULL; } /* Initialize pin control device struct */ pctldev->owner = pctldesc->owner; pctldev->desc = pctldesc; pctldev->driver_data = driver_data; INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL); INIT_LIST_HEAD(&pctldev->gpio_ranges); pctldev->dev = dev; mutex_init(&pctldev->mutex); /* check core ops for sanity */ if (pinctrl_check_ops(pctldev)) { dev_err(dev, "pinctrl ops lacks necessary functions\n"); goto out_err; } /* If we're implementing pinmuxing, check the ops for sanity */ if (pctldesc->pmxops) { if (pinmux_check_ops(pctldev)) goto out_err; } /* If we're implementing pinconfig, check the ops for sanity */ if (pctldesc->confops) { if (pinconf_check_ops(pctldev)) goto out_err; } /* Register all the pins */ dev_dbg(dev, "try to register %d pins ...\n", pctldesc->npins); ret = <API key>(pctldev, pctldesc->pins, pctldesc->npins); if (ret) { dev_err(dev, "error during pin registration\n"); <API key>(pctldev, pctldesc->pins, pctldesc->npins); goto out_err; } mutex_lock(&<API key>); list_add_tail(&pctldev->node, &pinctrldev_list); mutex_unlock(&<API key>); pctldev->p = pinctrl_get(pctldev->dev); if (!IS_ERR(pctldev->p)) { pctldev->hog_default = <API key>(pctldev->p, <API key>); if (IS_ERR(pctldev->hog_default)) { dev_dbg(dev, "failed to lookup the default state\n"); } else { if (<API key>(pctldev->p, pctldev->hog_default)) dev_err(dev, "failed to select default state\n"); } pctldev->hog_sleep = <API key>(pctldev->p, PINCTRL_STATE_SLEEP); if (IS_ERR(pctldev->hog_sleep)) dev_dbg(dev, "failed to lookup the sleep state\n"); } <API key>(pctldev); return pctldev; out_err: mutex_destroy(&pctldev->mutex); kfree(pctldev); return NULL; } EXPORT_SYMBOL_GPL(pinctrl_register); /** * pinctrl_unregister() - unregister pinmux * @pctldev: pin controller to unregister * * Called by pinmux drivers to unregister a pinmux. */ void pinctrl_unregister(struct pinctrl_dev *pctldev) { struct pinctrl_gpio_range *range, *n; if (pctldev == NULL) return; mutex_lock(&<API key>); mutex_lock(&pctldev->mutex); <API key>(pctldev); if (!IS_ERR(pctldev->p)) pinctrl_put(pctldev->p); /* TODO: check that no pinmuxes are still active? */ list_del(&pctldev->node); /* Destroy descriptor tree */ <API key>(pctldev, pctldev->desc->pins, pctldev->desc->npins); /* remove gpio ranges map */ <API key>(range, n, &pctldev->gpio_ranges, node) list_del(&range->node); mutex_unlock(&pctldev->mutex); mutex_destroy(&pctldev->mutex); kfree(pctldev); mutex_unlock(&<API key>); } EXPORT_SYMBOL_GPL(pinctrl_unregister); static int __init pinctrl_init(void) { pr_info("initialized pinctrl subsystem\n"); <API key>(); return 0; } /* init early since many drivers really need to initialized pinmux early */ core_initcall(pinctrl_init);
/* Custom mount options for our own purposes. */ /* Maybe these should now be freed for kernel use again */ #define MS_NOAUTO 0x80000000 #define MS_USERS 0x40000000 #define MS_USER 0x20000000 #define MS_OWNER 0x10000000 #define MS_GROUP 0x08000000 #define MS_PAMCONSOLE 0x04000000 #define MS_NETDEV 0x00040000 #define MS_COMMENT 0x00020000 #define MS_LOOP 0x00010000 /* Options that we keep the mount system call from seeing. */ #define MS_NOSYS (MS_NOAUTO|MS_USERS|MS_USER|MS_COMMENT|MS_LOOP|MS_PAMCONSOLE|MS_NETDEV) /* Options that we keep from appearing in the options field in the mtab. */ #define MS_NOMTAB (MS_REMOUNT|MS_NOAUTO|MS_USERS|MS_USER|MS_PAMCONSOLE) /* Options that we make ordinary users have by default. */ #define MS_SECURE (MS_NOEXEC|MS_NOSUID|MS_NODEV) /* Options that we make owner-mounted devices have by default */ #define MS_OWNERSECURE (MS_NOSUID|MS_NODEV) void parse_opts (char *options, int *flags, char **extra_opts); char *fix_opts_string (int flags, const char *extra_opts, const char *user);
#include "<API key>.h" #include <cutils/properties.h> #include "AudioLock.h" #include <stdint.h> #include <sys/types.h> #include <stdlib.h> static const uint32_t <API key> = 0; #define LOG_TAG "<API key>" namespace android { <API key> *<API key>::<API key> = NULL; <API key> *<API key>::getInstance() { AudioLock mGetInstanceLock; <API key> _l(mGetInstanceLock); if (<API key> == NULL) { <API key> = new <API key>(); } ASSERT(<API key> != NULL); return <API key>; } int <API key>::GetPropertyValue(const char* ProPerty_Key) { int result; char value[PROPERTY_VALUE_MAX]; property_get(ProPerty_Key, value, "0"); result = atoi(value); ALOGD("GetPropertyValue key = %s value = %d",ProPerty_Key,result); return result; } <API key>::<API key>() : mMixer(NULL) { ALOGD("%s()", __FUNCTION__); mMixer = mixer_open(<API key>); ALOGD("mMixer = %p", mMixer); ASSERT(mMixer != NULL); } <API key>::~<API key>() { ALOGD("%s()", __FUNCTION__); mixer_close(mMixer); mMixer = NULL; } } // end of namespace android
// { dg-do run { xfail sparc64-*-elf arm-*-pe } } // { dg-options "-fexceptions" } #include <exception> #include <stdlib.h> void <API key>() { exit(0); } void <API key>() throw() { throw 1; // { dg-warning "throw will always call terminate" "" { target c++1z } } } int main() { std::set_terminate(<API key>); <API key>(); return 1; }
package com.codename1.charts.transitions; import com.codename1.charts.ChartComponent; import com.codename1.charts.models.<API key>; import com.codename1.charts.models.XYSeries; /** * A transition to animate the values of a <API key> (used by BarChart). * @author shannah */ public class <API key> extends SeriesTransition { /** * The data set whose values are to be animated. */ private final <API key> dataset; /** * A buffer or cache dataset to store values before they are applied to the * target dataset. */ private <API key> datasetCache; /** * Transitions for the individual series of the dataset. */ private XYSeriesTransition[] seriesTransitions; /** * Creates a new transition for the given chart and dataset. The dataset * must be rendered by the given chart for this to work correctly. * @param chart * @param dataset */ public <API key>(ChartComponent chart, <API key> dataset) { super(chart); this.dataset = dataset; } /** * @inherit */ @Override protected void initTransition() { getBuffer(); // initializes the buffer and seriesTranslations int len = seriesTransitions.length; for (int i=0; i<len; i++){ seriesTransitions[i].initTransition(); } super.initTransition(); } /** * @inherit * @param progress */ @Override protected void update(int progress) { getBuffer(); // initializes the buffer and seriesTranslations int len = seriesTransitions.length; for (int i=0; i<len; i++){ seriesTransitions[i].update(progress); } } /** * @inherit */ @Override protected void cleanup() { super.cleanup(); getBuffer(); // initializes the buffer and seriesTranslations int len = seriesTransitions.length; for (int i=0; i<len; i++){ seriesTransitions[i].cleanup(); } } /** * Gets the buffer/cache for values. Values set in the buffer will be applied * to the target dataset when the transition takes place. * @return */ public <API key> getBuffer(){ if (datasetCache == null){ datasetCache = new <API key>(); for (int i=0; i<dataset.getSeriesCount(); i++){ datasetCache.addSeries(new XYSeries(dataset.getSeriesAt(i).getTitle())); } seriesTransitions = new XYSeriesTransition[dataset.getSeries().length]; int tlen = seriesTransitions.length; for (int i=0; i<tlen; i++){ seriesTransitions[i] = new XYSeriesTransition(getChart(), dataset.getSeriesAt(i)); seriesTransitions[i].setBuffer(datasetCache.getSeriesAt(i)); } } return datasetCache; } }
#include "KonquerorAdaptor.h" #include "konqmisc.h" #include "<API key>.h" #include "konqmainwindow.h" #include "konqviewmanager.h" #include "konqview.h" #include "konqsettingsxt.h" #include "konqsettings.h" #include <kapplication.h> #include <kdebug.h> #include <kwindowsystem.h> #include <QtCore/QFile> #ifdef Q_WS_X11 #include <QX11Info> #include <X11/Xlib.h> #endif // calls would have old user timestamps (for KWin's no-focus-stealing), // it's better to reset the timestamp and rely on other means // of detecting the time when the user action that triggered all this // happened // TODO a valid timestamp should be passed in the DBus calls that // are not for user scripting KonquerorAdaptor::KonquerorAdaptor() : QObject( kapp ) { QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject( KONQ_MAIN_PATH, this, QDBusConnection::<API key> ); } KonquerorAdaptor::~KonquerorAdaptor() { } QDBusObjectPath KonquerorAdaptor::openBrowserWindow( const QString& url, const QByteArray& startup_id ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif KonqMainWindow *res = KonqMisc::createSimpleWindow( KUrl(url), KParts::OpenUrlArguments() ); if ( !res ) return QDBusObjectPath("/"); return QDBusObjectPath( res->dbusName() ); } QDBusObjectPath KonquerorAdaptor::createNewWindow( const QString& url, const QString& mimetype, const QByteArray& startup_id, bool tempFile ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif KParts::OpenUrlArguments args; args.setMimeType( mimetype ); // Filter the URL, so that "kfmclient openURL gg:foo" works also when konq is already running KUrl finalURL = KonqMisc::konqFilteredURL( 0, url ); KonqOpenURLRequest req; req.args = args; req.tempFile = tempFile; KonqMainWindow *res = KonqMisc::createNewWindow(finalURL, req); if ( !res ) return QDBusObjectPath("/"); res->show(); return QDBusObjectPath( res->dbusName() ); } QDBusObjectPath KonquerorAdaptor::<API key>( const QString& url, const QStringList& filesToSelect, const QByteArray& startup_id ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif KonqOpenURLRequest req; req.filesToSelect = filesToSelect; KonqMainWindow *res = KonqMisc::createNewWindow(KUrl(url), req); if ( !res ) return QDBusObjectPath("/"); res->show(); return QDBusObjectPath( res->dbusName() ); } QDBusObjectPath KonquerorAdaptor::<API key>( const QString& path, const QString& filename, const QByteArray& startup_id ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif kDebug() << path << "," << filename; KonqMainWindow *res = KonqMisc::<API key>(path, filename); if ( !res ) return QDBusObjectPath("/"); res->show(); return QDBusObjectPath( res->dbusName() ); } QDBusObjectPath KonquerorAdaptor::<API key>( const QString& path, const QString& filename, const QString& url, const QByteArray& startup_id ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif KonqMainWindow *res = KonqMisc::<API key>( path, filename, KUrl(url) ); if ( !res ) return QDBusObjectPath("/"); res->show(); return QDBusObjectPath( res->dbusName() ); } QDBusObjectPath KonquerorAdaptor::<API key>( const QString& path, const QString& filename, const QString& url, const QString& mimetype, const QByteArray& startup_id ) { kapp->setStartupId( startup_id ); #ifdef Q_WS_X11 QX11Info::setAppUserTime( 0 ); #endif KParts::OpenUrlArguments args; args.setMimeType( mimetype ); KonqOpenURLRequest req; req.args = args; KonqMainWindow *res = KonqMisc::<API key>(path, filename, KUrl(url), req); if ( !res ) return QDBusObjectPath("/"); res->show(); return QDBusObjectPath( res->dbusName() ); } void KonquerorAdaptor::updateProfileList() { QList<KonqMainWindow*> *mainWindows = KonqMainWindow::mainWindowList(); if ( !mainWindows ) return; foreach ( KonqMainWindow* window, *mainWindows ) window->viewManager()->profileListDirty( false ); } QList<QDBusObjectPath> KonquerorAdaptor::getWindows() { QList<QDBusObjectPath> lst; QList<KonqMainWindow*> *mainWindows = KonqMainWindow::mainWindowList(); if ( mainWindows ) { foreach ( KonqMainWindow* window, *mainWindows ) lst.append( QDBusObjectPath( window->dbusName() ) ); } return lst; } QDBusObjectPath KonquerorAdaptor::windowForTab() { QList<KonqMainWindow*> *mainWindows = KonqMainWindow::mainWindowList(); if ( mainWindows ) { foreach ( KonqMainWindow* window, *mainWindows ) { #ifdef Q_WS_X11 KWindowInfo winfo = KWindowSystem::windowInfo( window->winId(), NET::WMDesktop ); if( winfo.isOnCurrentDesktop() && #else if( #endif !KonqMainWindow::isPreloaded() ) { // we want a tab in an already shown window Q_ASSERT(!window->dbusName().isEmpty()); return QDBusObjectPath( window->dbusName() ); } } } // We can't use QDBusObjectPath(), dbus type 'o' must be a valid object path. // So we use "/" as an indicator for not found. return QDBusObjectPath("/"); } bool KonquerorAdaptor::processCanBeReused( int screen ) { #ifdef Q_WS_X11 QX11Info info; if( info.screen() != screen ) return false; // this instance run on different screen, and Qt apps can't migrate #endif if( KonqMainWindow::isPreloaded()) return false; // will be handled by preloading related code instead QList<KonqMainWindow*>* windows = KonqMainWindow::mainWindowList(); if( windows == NULL ) return true; QStringList allowed_parts = KonqSettings::safeParts(); bool all_parts_allowed = false; if( allowed_parts.count() == 1 && allowed_parts.first() == QLatin1String( "SAFE" )) { allowed_parts.clear(); // is duplicated in client/kfmclient.cc allowed_parts << QLatin1String( "dolphinpart.desktop" ) << QLatin1String( "konq_sidebartng.desktop" ); } else if( allowed_parts.count() == 1 && allowed_parts.first() == QLatin1String( "ALL" )) { allowed_parts.clear(); all_parts_allowed = true; } if( all_parts_allowed ) return true; foreach ( KonqMainWindow* window, *windows ) { kDebug() << "processCanBeReused: count=" << window->viewCount(); const KonqMainWindow::MapViews& views = window->viewMap(); foreach ( KonqView* view, views ) { kDebug() << "processCanBeReused: part=" << view->service()->entryPath() << ", URL=" << view->url().prettyUrl(); if( !allowed_parts.contains( view->service()->entryPath())) return false; } } return true; } void KonquerorAdaptor::terminatePreloaded() { if( KonqMainWindow::isPreloaded()) kapp->exit(); } #include "KonquerorAdaptor.moc"
#include "ultima/shared/std/string.h" #include "ultima/nuvie/core/nuvie_defs.h" #include "ultima/nuvie/files/nuvie_io_file.h" #include "ultima/nuvie/conf/configuration.h" #include "ultima/nuvie/screen/screen.h" #include "ultima/nuvie/fonts/bmp_font.h" namespace Ultima { namespace Nuvie { BMPFont::BMPFont() { num_chars = 0; offset = 0; char_w = 0; char_h = 0; font_width_data = NULL; sdl_font_data = NULL; rune_mode = false; dual_font_mode = false; } BMPFont::~BMPFont() { if (sdl_font_data) { SDL_FreeSurface(sdl_font_data); } if (font_width_data) { free(font_width_data); } } bool BMPFont::init(Std::string bmp_filename, bool dual_fontmap) { dual_font_mode = dual_fontmap; num_chars = 256; Std::string full_filename = bmp_filename; full_filename += ".bmp"; sdl_font_data = SDL_LoadBMP(full_filename.c_str()); SDL_SetColorKey(sdl_font_data, SDL_TRUE, SDL_MapRGB(sdl_font_data->format, 0, 0x70, 0xfc)); char_w = sdl_font_data->w / 16; char_h = sdl_font_data->h / 16; //read font width data. For variable width fonts. full_filename = bmp_filename; full_filename += ".dat"; NuvieIOFileRead <API key>; if (<API key>.open(full_filename)) { font_width_data = <API key>.readAll(); <API key>.close(); } return true; } uint16 BMPFont::getStringWidth(const char *str, uint16 string_len) { uint16 i; uint16 w = 0; for (i = 0; i < string_len; i++) { if (dual_font_mode && str[i] == '<') { offset = 128; } else if (dual_font_mode && str[i] == '>') { offset = 0; } else { w += getCharWidth(str[i] + offset); } } return w; } uint16 BMPFont::getCharWidth(uint8 c) { if (font_width_data) { return font_width_data[c]; } return char_w; } uint16 BMPFont::drawChar(Screen *screen, uint8 char_num, uint16 x, uint16 y, uint8 color) { Common::Rect src; Common::Rect dst; if (dual_font_mode) { if (char_num == '<') { rune_mode = true; return 0; } else if (char_num == '>') { rune_mode = false; return 0; } } if (rune_mode) { char_num += 128; } src.left = (char_num % 16) * char_w; src.top = (char_num / 16) * char_h; src.setWidth(char_w); src.setHeight(char_h); dst.left = x; dst.top = y; dst.setWidth(char_w); dst.setHeight(char_h); SDL_BlitSurface(sdl_font_data, &src, screen->get_sdl_surface(), &dst); return getCharWidth(char_num); } } // End of namespace Nuvie } // End of namespace Ultima
#ifndef IMU_B2_H #define IMU_B2_H #include "subsystems/imu.h" #include "generated/airframe.h" #include "peripherals/max1168.h" /* type of magnetometer */ #define IMU_B2_MAG_NONE 0 #define IMU_B2_MAG_MS2100 1 #define IMU_B2_MAG_AMI601 2 #define IMU_B2_MAG_HMC5843 3 #define IMU_B2_MAG_HMC58XX 4 #ifdef IMU_B2_VERSION_1_0 /* Default IMU b2 sensors connection */ #if !defined IMU_GYRO_P_CHAN & !defined IMU_GYRO_Q_CHAN & !defined IMU_GYRO_R_CHAN #define IMU_GYRO_P_CHAN 1 #define IMU_GYRO_Q_CHAN 0 #define IMU_GYRO_R_CHAN 2 #endif #if !defined IMU_ACCEL_X_CHAN & !defined IMU_ACCEL_Y_CHAN & !defined IMU_ACCEL_Z_CHAN #define IMU_ACCEL_X_CHAN 3 #define IMU_ACCEL_Y_CHAN 5 #define IMU_ACCEL_Z_CHAN 6 #endif #if !defined IMU_MAG_X_CHAN & !defined IMU_MAG_Y_CHAN & !defined IMU_MAG_Z_CHAN #define IMU_MAG_X_CHAN 0 #define IMU_MAG_Y_CHAN 1 #define IMU_MAG_Z_CHAN 2 #endif #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN #define IMU_GYRO_P_SIGN 1 #define IMU_GYRO_Q_SIGN -1 #define IMU_GYRO_R_SIGN -1 #endif #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN #define IMU_ACCEL_X_SIGN -1 #define IMU_ACCEL_Y_SIGN -1 #define IMU_ACCEL_Z_SIGN -1 #endif #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN #define IMU_MAG_X_SIGN 1 #define IMU_MAG_Y_SIGN -1 #define IMU_MAG_Z_SIGN -1 #endif #endif /* IMU_B2_VERSION_1_0 */ #ifdef IMU_B2_VERSION_1_1 /* Default IMU b2 sensors connection */ #if !defined IMU_GYRO_P_CHAN & !defined IMU_GYRO_Q_CHAN & !defined IMU_GYRO_R_CHAN #define IMU_GYRO_P_CHAN 1 #define IMU_GYRO_Q_CHAN 0 #define IMU_GYRO_R_CHAN 2 #endif #if !defined IMU_ACCEL_X_CHAN & !defined IMU_ACCEL_Y_CHAN & !defined IMU_ACCEL_Z_CHAN #define IMU_ACCEL_X_CHAN 5 #define IMU_ACCEL_Y_CHAN 3 #define IMU_ACCEL_Z_CHAN 4 #endif #if !defined IMU_MAG_X_CHAN & !defined IMU_MAG_Y_CHAN & !defined IMU_MAG_Z_CHAN #define IMU_MAG_X_CHAN 0 #define IMU_MAG_Y_CHAN 1 #define IMU_MAG_Z_CHAN 2 #endif #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN #define IMU_GYRO_P_SIGN 1 #define IMU_GYRO_Q_SIGN -1 #define IMU_GYRO_R_SIGN -1 #endif #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN #define IMU_ACCEL_X_SIGN -1 #define IMU_ACCEL_Y_SIGN -1 #define IMU_ACCEL_Z_SIGN -1 #endif #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN #define IMU_MAG_X_SIGN 1 #define IMU_MAG_Y_SIGN -1 #define IMU_MAG_Z_SIGN -1 #endif #endif /* IMU_B2_VERSION_1_1 */ #ifdef IMU_B2_VERSION_1_2 /* Default IMU b2 sensors connection */ #if !defined IMU_GYRO_P_CHAN & !defined IMU_GYRO_Q_CHAN & !defined IMU_GYRO_R_CHAN #define IMU_GYRO_P_CHAN 1 #define IMU_GYRO_Q_CHAN 0 #define IMU_GYRO_R_CHAN 2 #endif #if !defined IMU_ACCEL_X_CHAN & !defined IMU_ACCEL_Y_CHAN & !defined IMU_ACCEL_Z_CHAN #define IMU_ACCEL_X_CHAN 4 #define IMU_ACCEL_Y_CHAN 5 #define IMU_ACCEL_Z_CHAN 3 #endif #if !defined IMU_MAG_X_CHAN & !defined IMU_MAG_Y_CHAN & !defined IMU_MAG_Z_CHAN #define IMU_MAG_X_CHAN 0 #define IMU_MAG_Y_CHAN 1 #define IMU_MAG_Z_CHAN 2 #endif #if !defined IMU_GYRO_P_SIGN & !defined IMU_GYRO_Q_SIGN & !defined IMU_GYRO_R_SIGN #define IMU_GYRO_P_SIGN 1 #define IMU_GYRO_Q_SIGN -1 #define IMU_GYRO_R_SIGN -1 #endif #if !defined IMU_ACCEL_X_SIGN & !defined IMU_ACCEL_Y_SIGN & !defined IMU_ACCEL_Z_SIGN #define IMU_ACCEL_X_SIGN 1 #define IMU_ACCEL_Y_SIGN -1 #define IMU_ACCEL_Z_SIGN 1 #endif #if !defined IMU_MAG_X_SIGN & !defined IMU_MAG_Y_SIGN & !defined IMU_MAG_Z_SIGN #define IMU_MAG_X_SIGN -1 #define IMU_MAG_Y_SIGN -1 #define IMU_MAG_Z_SIGN 1 #endif #endif /* IMU_B2_VERSION_1_2 */ #if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2100 #include "peripherals/ms2100.h" #define ImuMagEvent(_mag_handler) { \ if (ms2100_status == <API key>) { \ imu.mag_unscaled.x = ms2100_values[IMU_MAG_X_CHAN]; \ imu.mag_unscaled.y = ms2100_values[IMU_MAG_Y_CHAN]; \ imu.mag_unscaled.z = ms2100_values[IMU_MAG_Z_CHAN]; \ ms2100_status = MS2100_IDLE; \ _mag_handler(); \ } \ } #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_AMI601 #include "peripherals/ami601.h" #define foo_handler() {} #define ImuMagEvent(_mag_handler) { \ AMI601Event(foo_handler); \ if (ami601_status == <API key>) { \ imu.mag_unscaled.x = ami601_values[IMU_MAG_X_CHAN]; \ imu.mag_unscaled.y = ami601_values[IMU_MAG_Y_CHAN]; \ imu.mag_unscaled.z = ami601_values[IMU_MAG_Z_CHAN]; \ ami601_status = AMI601_IDLE; \ _mag_handler(); \ } \ } #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843 #include "peripherals/hmc5843.h" #define foo_handler() {} #define ImuMagEvent(_mag_handler) { \ MagEvent(foo_handler); \ if (hmc5843.data_available) { \ imu.mag_unscaled.x = hmc5843.data.value[IMU_MAG_X_CHAN]; \ imu.mag_unscaled.y = hmc5843.data.value[IMU_MAG_Y_CHAN]; \ imu.mag_unscaled.z = hmc5843.data.value[IMU_MAG_Z_CHAN]; \ _mag_handler(); \ hmc5843.data_available = FALSE; \ } \ } #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC58XX #include "peripherals/hmc58xx.h" #define foo_handler() {} #define ImuMagEvent(_mag_handler) { \ MagEvent(foo_handler); \ if (<API key>) { \ imu.mag_unscaled.x = hmc58xx_data.x; \ imu.mag_unscaled.y = hmc58xx_data.y; \ imu.mag_unscaled.z = hmc58xx_data.z; \ _mag_handler(); \ <API key> = FALSE; \ } \ } #else #define ImuMagEvent(_mag_handler) {} #define ImuScaleMag(_imu) {} #endif #define ImuEvent(_gyro_handler, _accel_handler, _mag_handler) { \ if (max1168_status == <API key>) { \ imu.gyro_unscaled.p = max1168_values[IMU_GYRO_P_CHAN]; \ imu.gyro_unscaled.q = max1168_values[IMU_GYRO_Q_CHAN]; \ imu.gyro_unscaled.r = max1168_values[IMU_GYRO_R_CHAN]; \ imu.accel_unscaled.x = max1168_values[IMU_ACCEL_X_CHAN]; \ imu.accel_unscaled.y = max1168_values[IMU_ACCEL_Y_CHAN]; \ imu.accel_unscaled.z = max1168_values[IMU_ACCEL_Z_CHAN]; \ max1168_status = STA_MAX1168_IDLE; \ _gyro_handler(); \ _accel_handler(); \ } \ ImuMagEvent(_mag_handler); \ } /* underlying architecture */ #include "subsystems/imu/imu_b2_arch.h" /* must be implemented by underlying architecture */ extern void imu_b2_arch_init(void); #endif /* IMU_B2_H */
// RUN: %clang_cc1 %s -verify -fsyntax-only int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}} void g() __attribute__((deprecated)); void g(); // expected-note {{'g' has been explicitly marked deprecated here}} extern int var __attribute__((deprecated)); // expected-note {{'var' has been explicitly marked deprecated here}} int a() { int (*ptr)() = f; // expected-warning {{'f' is deprecated}} f(); // expected-warning {{'f' is deprecated}} // test if attributes propagate to functions g(); // expected-warning {{'g' is deprecated}} return var; // expected-warning {{'var' is deprecated}} } // test if attributes propagate to variables extern int var; // expected-note {{'var' has been explicitly marked deprecated here}} int w() { return var; // expected-warning {{'var' is deprecated}} } int old_fn() __attribute__ ((deprecated)); int old_fn(); // expected-note {{'old_fn' has been explicitly marked deprecated here}} int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}} int old_fn() { return old_fn()+1; // no warning, deprecated functions can use deprecated symbols. } struct foo { int x __attribute__((deprecated)); // expected-note 3 {{'x' has been explicitly marked deprecated here}} }; void test1(struct foo *F) { ++F->x; // expected-warning {{'x' is deprecated}} struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}} struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}} } typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{'foo_dep' has been explicitly marked deprecated here}} foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} struct __attribute__((deprecated, invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}} struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} // These should not warn because the actually declaration itself is deprecated. // rdar://6756623 foo_dep *test4 __attribute__((deprecated)); struct bar_dep *test5 __attribute__((deprecated)); typedef foo_dep test6(struct bar_dep*); // expected-warning {{'foo_dep' is deprecated}} \ // expected-warning {{'bar_dep' is deprecated}} typedef foo_dep test7(struct bar_dep*) __attribute__((deprecated)); int test8(char *p) { p += sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}} foo_dep *ptr; // expected-warning {{'foo_dep' is deprecated}} ptr = (foo_dep*) p; // expected-warning {{'foo_dep' is deprecated}} int func(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}} return func(ptr); } foo_dep *test9(void) __attribute__((deprecated)); foo_dep *test9(void) { void* myalloc(unsigned long); foo_dep *ptr = (foo_dep*) myalloc(sizeof(foo_dep)); return ptr; } void test10(void) __attribute__((deprecated)); void test10(void) { if (sizeof(foo_dep) == sizeof(void*)) { } foo_dep *localfunc(void); foo_dep localvar; } char test11[sizeof(foo_dep)] __attribute__((deprecated)); char test12[sizeof(foo_dep)]; // expected-warning {{'foo_dep' is deprecated}} int test13(foo_dep *foo) __attribute__((deprecated)); int test14(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}} unsigned long test15 = sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}} unsigned long test16 __attribute__((deprecated)) = sizeof(foo_dep); foo_dep test17, // expected-warning {{'foo_dep' is deprecated}} test18 __attribute__((deprecated)), test19; // rdar://problem/8518751 enum __attribute__((deprecated)) Test20 { // expected-note {{'Test20' has been explicitly marked deprecated here}} test20_a __attribute__((deprecated)), // expected-note {{'test20_a' has been explicitly marked deprecated here}} test20_b // expected-note {{'test20_b' has been explicitly marked deprecated here}} }; void test20() { enum Test20 f; // expected-warning {{'Test20' is deprecated}} f = test20_a; // expected-warning {{'test20_a' is deprecated}} f = test20_b; // expected-warning {{'test20_b' is deprecated}} } char test21[__has_feature(<API key>) ? 1 : -1]; struct test22 { foo_dep a __attribute((deprecated)); foo_dep b; // expected-warning {{'foo_dep' is deprecated}} foo_dep c, d __attribute((deprecated)); // expected-warning {{'foo_dep' is deprecated}} __attribute((deprecated)) foo_dep e, f; }; typedef int test23_ty __attribute((deprecated)); typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}} test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
// { dg-do run { target c++11 } } // { dg-require-cstdint "" } // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // with this library; see the file COPYING3. If not see #include <random> void test01() { double seed = 2.0; std::<API key>< unsigned long, 32, 624, 397, 31, 0x9908b0dful, 11, 0xfffffffful, 7, 0x9d2c5680ul, 15, 0xefc60000ul, 18, 1812433253ul> x(seed); } int main() { test01(); return 0; }
#include <linux/workqueue.h> #include <linux/delay.h> #include <linux/kobject.h> #include <linux/sysfs.h> #include "mdss_dsi.h" #include "mdss_mdp.h" /* * <API key>() - Check MDP5 DSI controller status periodically. * @work : dsi controller status data * @interval : duration in milliseconds to schedule work queue * * This function calls check_status API on DSI controller to send the BTA * command. If DSI controller fails to acknowledge the BTA command, it sends * the PANEL_ALIVE=0 status to HAL layer. */ void <API key>(struct work_struct *work, uint32_t interval) { struct dsi_status_data *pstatus_data = NULL; struct mdss_panel_data *pdata = NULL; struct mipi_panel_info *mipi = NULL; struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL; struct <API key> *mdp5_data = NULL; struct mdss_mdp_ctl *ctl = NULL; int ret = 0; pstatus_data = container_of(to_delayed_work(work), struct dsi_status_data, check_status); if (!pstatus_data || !(pstatus_data->mfd)) { pr_err("%s: mfd not available\n", __func__); return; } pdata = dev_get_platdata(&pstatus_data->mfd->pdev->dev); if (!pdata) { pr_err("%s: Panel data not available\n", __func__); return; } mipi = &pdata->panel_info.mipi; ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data); if (!ctrl_pdata || !ctrl_pdata->check_status) { pr_err("%s: DSI ctrl or status_check callback not available\n", __func__); return; } mdp5_data = mfd_to_mdp5_data(pstatus_data->mfd); ctl = mfd_to_ctl(pstatus_data->mfd); if (!ctl) { pr_err("%s: Display is off\n", __func__); return; } if (ctl->power_state == <API key>) { <API key>(&pstatus_data->check_status, msecs_to_jiffies(interval)); pr_err("%s: ctl not powered on\n", __func__); return; } mutex_lock(&ctrl_pdata->mutex); /* * TODO: Because <API key> has made sure DMA to * be idle in <API key>, it is not necessary * to acquire ov_lock in case of video mode. Removing this * lock to fix issues so that ESD thread would not block other * overlay operations. Need refine this lock for command mode */ if (mipi->mode == DSI_CMD_MODE) mutex_lock(&mdp5_data->ov_lock); if (<API key>(pstatus_data->mfd->panel_power_state)) { if (mipi->mode == DSI_CMD_MODE) mutex_unlock(&mdp5_data->ov_lock); mutex_unlock(&ctrl_pdata->mutex); pr_err("%s: DSI turning off, avoiding panel status check\n", __func__); return; } /* * For the command mode panels, we return pan display * IOCTL on vsync interrupt. So, after vsync interrupt comes * and when DMA_P is in progress, if the panel stops responding * and if we trigger BTA before DMA_P finishes, then the DSI * FIFO will not be cleared since the DSI data bus control * doesn't come back to the host after BTA. This may cause the * display reset not to be proper. Hence, wait for DMA_P done * for command mode panels before triggering BTA. */ if (ctl->wait_pingpong) ctl->wait_pingpong(ctl, NULL); pr_debug("%s: DSI ctrl wait for ping pong done\n", __func__); mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false); ret = ctrl_pdata->check_status(ctrl_pdata); mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false); if (mipi->mode == DSI_CMD_MODE) mutex_unlock(&mdp5_data->ov_lock); mutex_unlock(&ctrl_pdata->mutex); if ((pstatus_data->mfd->panel_power_state == MDSS_PANEL_POWER_ON)) { if (ret > 0) { <API key>(&pstatus_data->check_status, msecs_to_jiffies(interval)); } else { char *envp[2] = {"PANEL_ALIVE=0", NULL}; pdata->panel_info.panel_dead = true; ret = kobject_uevent_env( &pstatus_data->mfd->fbi->dev->kobj, KOBJ_CHANGE, envp); pr_err("%s: Panel has gone bad, sending uevent - %s\n", __func__, envp[0]); } } }
#!/bin/bash # This code is free software; you can redistribute it and/or modify it # published by the Free Software Foundation. # This code is distributed in the hope that it will be useful, but WITHOUT # accompanied this code). # 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 # questions. hg status|grep ^\?|awk '{print $2}'|xargs rm
// <API key>: GPL-2.0 #include <linux/export.h> #include "dm_common.h" #include "phy_common.h" #include "../pci.h" #include "../base.h" #include "../core.h" #define <API key> <API key>(0, 1) #define <API key> <API key>(1, 1) #define <API key> <API key>(2, 1) #define <API key> <API key>(3, 1) #define <API key> <API key>(4, 1) #define BT_MASK 0x00ffffff #define RTLPRIV (struct rtl_priv *) #define <API key>(_priv) \ ((RTLPRIV(_priv))->mac80211.opmode == \ <API key>) ? \ ((RTLPRIV(_priv))->dm.<API key>) : \ ((RTLPRIV(_priv))->dm.undec_sm_pwdb) static const u32 ofdmswing_table[OFDM_TABLE_SIZE] = { 0x7f8001fe, 0x788001e2, 0x71c001c7, 0x6b8001ae, 0x65400195, 0x5fc0017f, 0x5a400169, 0x55400155, 0x50800142, 0x4c000130, 0x47c0011f, 0x43c0010f, 0x40000100, 0x3c8000f2, 0x390000e4, 0x35c000d7, 0x32c000cb, 0x300000c0, 0x2d4000b5, 0x2ac000ab, 0x288000a2, 0x26000098, 0x24000090, 0x22000088, 0x20000080, 0x1e400079, 0x1c800072, 0x1b00006c, 0x19800066, 0x18000060, 0x16c0005b, 0x15800056, 0x14400051, 0x1300004c, 0x12000048, 0x11000044, 0x10000040, }; static const u8 <API key>[CCK_TABLE_SIZE][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} }; static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = { {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} }; static u32 power_index_reg[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a}; void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); u8 index; for (index = 0; index < 6; index++) rtl_write_byte(rtlpriv, power_index_reg[index], rtlpriv->dm.powerindex_backup[index]); } EXPORT_SYMBOL_GPL(<API key>); void dm_writepowerindex(struct ieee80211_hw *hw, u8 value) { struct rtl_priv *rtlpriv = rtl_priv(hw); u8 index; for (index = 0; index < 6; index++) rtl_write_byte(rtlpriv, power_index_reg[index], value); } EXPORT_SYMBOL_GPL(dm_writepowerindex); void dm_savepowerindex(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); u8 index; u8 tmp; for (index = 0; index < 6; index++) { tmp = rtl_read_byte(rtlpriv, power_index_reg[index]); rtlpriv->dm.powerindex_backup[index] = tmp; } } EXPORT_SYMBOL_GPL(dm_savepowerindex); static u8 <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; long rssi_val_min = 0; if ((dm_digtable->curmultista_cstate == <API key>) && (dm_digtable->cursta_cstate == DIG_STA_CONNECT)) { if (rtlpriv->dm.<API key> != 0) rssi_val_min = (rtlpriv->dm.<API key> > rtlpriv->dm.undec_sm_pwdb) ? rtlpriv->dm.undec_sm_pwdb : rtlpriv->dm.<API key>; else rssi_val_min = rtlpriv->dm.undec_sm_pwdb; } else if (dm_digtable->cursta_cstate == DIG_STA_CONNECT || dm_digtable->cursta_cstate == <API key>) { rssi_val_min = rtlpriv->dm.undec_sm_pwdb; } else if (dm_digtable->curmultista_cstate == <API key>) { rssi_val_min = rtlpriv->dm.<API key>; } if (rssi_val_min > 100) rssi_val_min = 100; return (u8)rssi_val_min; } static void <API key>(struct ieee80211_hw *hw) { u32 ret_value; struct rtl_priv *rtlpriv = rtl_priv(hw); struct <API key> *falsealm_cnt = &(rtlpriv->falsealm_cnt); ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER1, MASKDWORD); falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16); ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER2, MASKDWORD); falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff); falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16); ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER3, MASKDWORD); falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff); ret_value = rtl_get_bbreg(hw, ROFDM0_FRAMESYNC, MASKDWORD); falsealm_cnt->cnt_fast_fsync_fail = (ret_value & 0xffff); falsealm_cnt->cnt_sb_search_fail = ((ret_value & 0xffff0000) >> 16); falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail + falsealm_cnt->cnt_rate_illegal + falsealm_cnt->cnt_crc8_fail + falsealm_cnt->cnt_mcs_fail + falsealm_cnt->cnt_fast_fsync_fail + falsealm_cnt->cnt_sb_search_fail; rtl_set_bbreg(hw, <API key>, BIT(14), 1); ret_value = rtl_get_bbreg(hw, <API key>, MASKBYTE0); falsealm_cnt->cnt_cck_fail = ret_value; ret_value = rtl_get_bbreg(hw, <API key>, MASKBYTE3); falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8; falsealm_cnt->cnt_all = (falsealm_cnt->cnt_parity_fail + falsealm_cnt->cnt_rate_illegal + falsealm_cnt->cnt_crc8_fail + falsealm_cnt->cnt_mcs_fail + falsealm_cnt->cnt_cck_fail); rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 1); rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 0); rtl_set_bbreg(hw, <API key>, 0x0000c000, 0); rtl_set_bbreg(hw, <API key>, 0x0000c000, 2); RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", falsealm_cnt->cnt_parity_fail, falsealm_cnt->cnt_rate_illegal, falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail); RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", falsealm_cnt->cnt_ofdm_fail, falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all); } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; u8 value_igi = dm_digtable->cur_igvalue; if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0) value_igi else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH1) value_igi += 0; else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH2) value_igi++; else if (rtlpriv->falsealm_cnt.cnt_all >= DM_DIG_FA_TH2) value_igi += 2; if (value_igi > DM_DIG_FA_UPPER) value_igi = DM_DIG_FA_UPPER; else if (value_igi < DM_DIG_FA_LOWER) value_igi = DM_DIG_FA_LOWER; if (rtlpriv->falsealm_cnt.cnt_all > 10000) value_igi = DM_DIG_FA_UPPER; dm_digtable->cur_igvalue = value_igi; rtl92c_dm_write_dig(hw); } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *digtable = &rtlpriv->dm_digtable; u32 isbt; /* modify DIG lower bound, deal with abnormally large false alarm */ if (rtlpriv->falsealm_cnt.cnt_all > 10000) { digtable->large_fa_hit++; if (digtable->forbidden_igi < digtable->cur_igvalue) { digtable->forbidden_igi = digtable->cur_igvalue; digtable->large_fa_hit = 1; } if (digtable->large_fa_hit >= 3) { if ((digtable->forbidden_igi + 1) > digtable->rx_gain_max) digtable->rx_gain_min = digtable->rx_gain_max; else digtable->rx_gain_min = (digtable->forbidden_igi + 1); digtable->recover_cnt = 3600; /* 3600=2hr */ } } else { /* Recovery mechanism for IGI lower bound */ if (digtable->recover_cnt != 0) { digtable->recover_cnt } else { if (digtable->large_fa_hit == 0) { if ((digtable->forbidden_igi-1) < DM_DIG_MIN) { digtable->forbidden_igi = DM_DIG_MIN; digtable->rx_gain_min = DM_DIG_MIN; } else { digtable->forbidden_igi digtable->rx_gain_min = digtable->forbidden_igi + 1; } } else if (digtable->large_fa_hit == 3) { digtable->large_fa_hit = 0; } } } if (rtlpriv->falsealm_cnt.cnt_all < 250) { isbt = rtl_read_byte(rtlpriv, 0x4fd) & 0x01; if (!isbt) { if (rtlpriv->falsealm_cnt.cnt_all > digtable->fa_lowthresh) { if ((digtable->back_val - 2) < digtable->back_range_min) digtable->back_val = digtable->back_range_min; else digtable->back_val -= 2; } else if (rtlpriv->falsealm_cnt.cnt_all < digtable->fa_lowthresh) { if ((digtable->back_val + 2) > digtable->back_range_max) digtable->back_val = digtable->back_range_max; else digtable->back_val += 2; } } else { digtable->back_val = <API key>; } } else { /* Adjust initial gain by false alarm */ if (rtlpriv->falsealm_cnt.cnt_all > 1000) digtable->cur_igvalue = digtable->pre_igvalue + 2; else if (rtlpriv->falsealm_cnt.cnt_all > 750) digtable->cur_igvalue = digtable->pre_igvalue + 1; else if (rtlpriv->falsealm_cnt.cnt_all < 500) digtable->cur_igvalue = digtable->pre_igvalue - 1; } /* Check initial gain by upper/lower bound */ if (digtable->cur_igvalue > digtable->rx_gain_max) digtable->cur_igvalue = digtable->rx_gain_max; if (digtable->cur_igvalue < digtable->rx_gain_min) digtable->cur_igvalue = digtable->rx_gain_min; rtl92c_dm_write_dig(hw); } static void <API key>(struct ieee80211_hw *hw) { static u8 initialized; /* initialized to false */ struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); long rssi_strength = rtlpriv->dm.<API key>; bool multi_sta = false; if (mac->opmode == <API key>) multi_sta = true; if (!multi_sta || dm_digtable->cursta_cstate == DIG_STA_DISCONNECT) { initialized = false; dm_digtable->dig_ext_port_stage = <API key>; return; } else if (initialized == false) { initialized = true; dm_digtable->dig_ext_port_stage = <API key>; dm_digtable->cur_igvalue = 0x20; rtl92c_dm_write_dig(hw); } if (dm_digtable->curmultista_cstate == <API key>) { if ((rssi_strength < dm_digtable->rssi_lowthresh) && (dm_digtable->dig_ext_port_stage != <API key>)) { if (dm_digtable->dig_ext_port_stage == <API key>) { dm_digtable->cur_igvalue = 0x20; rtl92c_dm_write_dig(hw); } dm_digtable->dig_ext_port_stage = <API key>; } else if (rssi_strength > dm_digtable->rssi_highthresh) { dm_digtable->dig_ext_port_stage = <API key>; <API key>(hw); } } else if (dm_digtable->dig_ext_port_stage != <API key>) { dm_digtable->dig_ext_port_stage = <API key>; dm_digtable->cur_igvalue = 0x20; rtl92c_dm_write_dig(hw); } RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "curmultista_cstate = %x dig_ext_port_stage %x\n", dm_digtable->curmultista_cstate, dm_digtable->dig_ext_port_stage); } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, "presta_cstate = %x, cursta_cstate = %x\n", dm_digtable->presta_cstate, dm_digtable->cursta_cstate); if (dm_digtable->presta_cstate == dm_digtable->cursta_cstate || dm_digtable->cursta_cstate == <API key> || dm_digtable->cursta_cstate == DIG_STA_CONNECT) { if (dm_digtable->cursta_cstate != DIG_STA_DISCONNECT) { dm_digtable->rssi_val_min = <API key>(hw); if (dm_digtable->rssi_val_min > 100) dm_digtable->rssi_val_min = 100; <API key>(hw); } } else { dm_digtable->rssi_val_min = 0; dm_digtable->dig_ext_port_stage = <API key>; dm_digtable->back_val = <API key>; dm_digtable->cur_igvalue = 0x20; dm_digtable->pre_igvalue = 0; rtl92c_dm_write_dig(hw); } } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; if (dm_digtable->cursta_cstate == DIG_STA_CONNECT) { dm_digtable->rssi_val_min = <API key>(hw); if (dm_digtable->rssi_val_min > 100) dm_digtable->rssi_val_min = 100; if (dm_digtable->pre_cck_pd_state == <API key>) { if (dm_digtable->rssi_val_min <= 25) dm_digtable->cur_cck_pd_state = <API key>; else dm_digtable->cur_cck_pd_state = <API key>; } else { if (dm_digtable->rssi_val_min <= 20) dm_digtable->cur_cck_pd_state = <API key>; else dm_digtable->cur_cck_pd_state = <API key>; } } else { dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX; } if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) { if ((dm_digtable->cur_cck_pd_state == <API key>) || (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_MAX)) rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0x83); else rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); dm_digtable->pre_cck_pd_state = dm_digtable->cur_cck_pd_state; } } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); if (mac->act_scanning) return; if (mac->link_state >= MAC80211_LINKED) dm_digtable->cursta_cstate = DIG_STA_CONNECT; else dm_digtable->cursta_cstate = DIG_STA_DISCONNECT; dm_digtable->curmultista_cstate = <API key>; <API key>(hw); <API key>(hw); <API key>(hw); dm_digtable->presta_cstate = dm_digtable->cursta_cstate; } static void rtl92c_dm_dig(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); if (rtlpriv->dm.<API key> == false) return; if (!(rtlpriv->dm.dm_flag & DYNAMIC_FUNC_DIG)) return; <API key>(hw); } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); if (rtlpriv->rtlhal.interface == INTF_USB && rtlpriv->rtlhal.board_type & 0x1) { dm_savepowerindex(hw); rtlpriv->dm.<API key> = true; } else { rtlpriv->dm.<API key> = false; } rtlpriv->dm.last_dtp_lvl = <API key>; rtlpriv->dm.<API key> = <API key>; } void rtl92c_dm_write_dig(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct dig_t *dm_digtable = &rtlpriv->dm_digtable; RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "cur_igvalue = 0x%x, pre_igvalue = 0x%x, back_val = %d\n", dm_digtable->cur_igvalue, dm_digtable->pre_igvalue, dm_digtable->back_val); if (rtlpriv->rtlhal.interface == INTF_USB && !dm_digtable->dig_enable_flag) { dm_digtable->pre_igvalue = 0x17; return; } dm_digtable->cur_igvalue -= 1; if (dm_digtable->cur_igvalue < DM_DIG_MIN) dm_digtable->cur_igvalue = DM_DIG_MIN; if (dm_digtable->pre_igvalue != dm_digtable->cur_igvalue) { rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, dm_digtable->cur_igvalue); rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f, dm_digtable->cur_igvalue); dm_digtable->pre_igvalue = dm_digtable->cur_igvalue; } RT_TRACE(rtlpriv, COMP_DIG, DBG_WARNING, "dig values 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", dm_digtable->cur_igvalue, dm_digtable->pre_igvalue, dm_digtable->rssi_val_min, dm_digtable->back_val, dm_digtable->rx_gain_max, dm_digtable->rx_gain_min, dm_digtable->large_fa_hit, dm_digtable->forbidden_igi); } EXPORT_SYMBOL(rtl92c_dm_write_dig); static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); long tmpentry_max_pwdb = 0, tmpentry_min_pwdb = 0xff; if (mac->link_state != MAC80211_LINKED) return; if (mac->opmode == <API key> || mac->opmode == NL80211_IFTYPE_AP) { /* TODO: Handle ADHOC and AP Mode */ } if (tmpentry_max_pwdb != 0) rtlpriv->dm.<API key> = tmpentry_max_pwdb; else rtlpriv->dm.<API key> = 0; if (tmpentry_min_pwdb != 0xff) rtlpriv->dm.<API key> = tmpentry_min_pwdb; else rtlpriv->dm.<API key> = 0; /* TODO: * if (mac->opmode == <API key>) { * if (rtlpriv->rtlhal.fw_ready) { * u32 param = (u32)(rtlpriv->dm.undec_sm_pwdb << 16); * <API key>(hw, param); * } * } */ } void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); rtlpriv->dm.current_turbo_edca = false; rtlpriv->dm.is_any_nonbepkts = false; rtlpriv->dm.is_cur_rdlstate = false; } EXPORT_SYMBOL(<API key>); static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); static u64 last_txok_cnt; static u64 last_rxok_cnt; static u32 last_bt_edca_ul; static u32 last_bt_edca_dl; u64 cur_txok_cnt = 0; u64 cur_rxok_cnt = 0; u32 edca_be_ul = 0x5ea42b; u32 edca_be_dl = 0x5ea42b; bool bt_change_edca = false; if ((last_bt_edca_ul != rtlpriv->btcoexist.bt_edca_ul) || (last_bt_edca_dl != rtlpriv->btcoexist.bt_edca_dl)) { rtlpriv->dm.current_turbo_edca = false; last_bt_edca_ul = rtlpriv->btcoexist.bt_edca_ul; last_bt_edca_dl = rtlpriv->btcoexist.bt_edca_dl; } if (rtlpriv->btcoexist.bt_edca_ul != 0) { edca_be_ul = rtlpriv->btcoexist.bt_edca_ul; bt_change_edca = true; } if (rtlpriv->btcoexist.bt_edca_dl != 0) { edca_be_ul = rtlpriv->btcoexist.bt_edca_dl; bt_change_edca = true; } if (mac->link_state != MAC80211_LINKED) { rtlpriv->dm.current_turbo_edca = false; return; } if ((!mac->ht_enable) && (!rtlpriv->btcoexist.bt_coexistence)) { if (!(edca_be_ul & 0xffff0000)) edca_be_ul |= 0x005e0000; if (!(edca_be_dl & 0xffff0000)) edca_be_dl |= 0x005e0000; } if ((bt_change_edca) || ((!rtlpriv->dm.is_any_nonbepkts) && (!rtlpriv->dm.<API key>))) { cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt; cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt; if (cur_rxok_cnt > 4 * cur_txok_cnt) { if (!rtlpriv->dm.is_cur_rdlstate || !rtlpriv->dm.current_turbo_edca) { rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, edca_be_dl); rtlpriv->dm.is_cur_rdlstate = true; } } else { if (rtlpriv->dm.is_cur_rdlstate || !rtlpriv->dm.current_turbo_edca) { rtl_write_dword(rtlpriv, REG_EDCA_BE_PARAM, edca_be_ul); rtlpriv->dm.is_cur_rdlstate = false; } } rtlpriv->dm.current_turbo_edca = true; } else { if (rtlpriv->dm.current_turbo_edca) { u8 tmp = AC0_BE; rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AC_PARAM, &tmp); rtlpriv->dm.current_turbo_edca = false; } } rtlpriv->dm.is_any_nonbepkts = false; last_txok_cnt = rtlpriv->stats.txbytesunicast; last_rxok_cnt = rtlpriv->stats.rxbytesunicast; } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); u8 thermalvalue, delta, delta_lck, delta_iqk; long ele_a, ele_d, temp_cck, val_x, value32; long val_y, ele_c = 0; u8 ofdm_index[2], ofdm_index_old[2] = {0, 0}, cck_index_old = 0; s8 cck_index = 0; int i; bool is2t = IS_92C_SERIAL(rtlhal->version); s8 txpwr_level[3] = {0, 0, 0}; u8 ofdm_min_index = 6, rf; rtlpriv->dm.<API key> = true; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<API key>\n"); thermalvalue = (u8) rtl_get_rfreg(hw, RF90_PATH_A, RF_T_METER, 0x1f); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x\n", thermalvalue, rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter); <API key>(hw, (thermalvalue - rtlefuse->eeprom_thermalmeter)); if (is2t) rf = 2; else rf = 1; if (thermalvalue) { ele_d = rtl_get_bbreg(hw, <API key>, MASKDWORD) & MASKOFDM_D; for (i = 0; i < OFDM_TABLE_LENGTH; i++) { if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) { ofdm_index_old[0] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Initial pathA ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n", <API key>, ele_d, ofdm_index_old[0]); break; } } if (is2t) { ele_d = rtl_get_bbreg(hw, <API key>, MASKDWORD) & MASKOFDM_D; for (i = 0; i < OFDM_TABLE_LENGTH; i++) { if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) { ofdm_index_old[1] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Initial pathB ele_d reg0x%x = 0x%lx, ofdm_index=0x%x\n", <API key>, ele_d, ofdm_index_old[1]); break; } } } temp_cck = rtl_get_bbreg(hw, RCCK0_TXFILTER2, MASKDWORD) & MASKCCK; for (i = 0; i < CCK_TABLE_LENGTH; i++) { if (rtlpriv->dm.cck_inch14) { if (memcmp((void *)&temp_cck, (void *)&cckswing_table_ch14[i][2], 4) == 0) { cck_index_old = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch 14 %d\n", RCCK0_TXFILTER2, temp_cck, cck_index_old, rtlpriv->dm.cck_inch14); break; } } else { if (memcmp((void *)&temp_cck, (void *) &<API key>[i][2], 4) == 0) { cck_index_old = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Initial reg0x%x = 0x%lx, cck_index=0x%x, ch14 %d\n", RCCK0_TXFILTER2, temp_cck, cck_index_old, rtlpriv->dm.cck_inch14); break; } } } if (!rtlpriv->dm.thermalvalue) { rtlpriv->dm.thermalvalue = rtlefuse->eeprom_thermalmeter; rtlpriv->dm.thermalvalue_lck = thermalvalue; rtlpriv->dm.thermalvalue_iqk = thermalvalue; for (i = 0; i < rf; i++) rtlpriv->dm.ofdm_index[i] = ofdm_index_old[i]; rtlpriv->dm.cck_index = cck_index_old; } /* Handle USB High PA boards */ delta = (thermalvalue > rtlpriv->dm.thermalvalue) ? (thermalvalue - rtlpriv->dm.thermalvalue) : (rtlpriv->dm.thermalvalue - thermalvalue); delta_lck = (thermalvalue > rtlpriv->dm.thermalvalue_lck) ? (thermalvalue - rtlpriv->dm.thermalvalue_lck) : (rtlpriv->dm.thermalvalue_lck - thermalvalue); delta_iqk = (thermalvalue > rtlpriv->dm.thermalvalue_iqk) ? (thermalvalue - rtlpriv->dm.thermalvalue_iqk) : (rtlpriv->dm.thermalvalue_iqk - thermalvalue); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Readback Thermal Meter = 0x%x pre thermal meter 0x%x eeprom_thermalmeter 0x%x delta 0x%x delta_lck 0x%x delta_iqk 0x%x\n", thermalvalue, rtlpriv->dm.thermalvalue, rtlefuse->eeprom_thermalmeter, delta, delta_lck, delta_iqk); if (delta_lck > 1) { rtlpriv->dm.thermalvalue_lck = thermalvalue; <API key>(hw); } if (delta > 0 && rtlpriv->dm.<API key>) { if (thermalvalue > rtlpriv->dm.thermalvalue) { for (i = 0; i < rf; i++) rtlpriv->dm.ofdm_index[i] -= delta; rtlpriv->dm.cck_index -= delta; } else { for (i = 0; i < rf; i++) rtlpriv->dm.ofdm_index[i] += delta; rtlpriv->dm.cck_index += delta; } if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n", rtlpriv->dm.ofdm_index[0], rtlpriv->dm.ofdm_index[1], rtlpriv->dm.cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "temp OFDM_A_index=0x%x, cck_index=0x%x\n", rtlpriv->dm.ofdm_index[0], rtlpriv->dm.cck_index); } if (thermalvalue > rtlefuse->eeprom_thermalmeter) { for (i = 0; i < rf; i++) ofdm_index[i] = rtlpriv->dm.ofdm_index[i] + 1; cck_index = rtlpriv->dm.cck_index + 1; } else { for (i = 0; i < rf; i++) ofdm_index[i] = rtlpriv->dm.ofdm_index[i]; cck_index = rtlpriv->dm.cck_index; } for (i = 0; i < rf; i++) { if (txpwr_level[i] >= 0 && txpwr_level[i] <= 26) { if (thermalvalue > rtlefuse->eeprom_thermalmeter) { if (delta < 5) ofdm_index[i] -= 1; else ofdm_index[i] -= 2; } else if (delta > 5 && thermalvalue < rtlefuse-> eeprom_thermalmeter) { ofdm_index[i] += 1; } } else if (txpwr_level[i] >= 27 && txpwr_level[i] <= 32 && thermalvalue > rtlefuse->eeprom_thermalmeter) { if (delta < 5) ofdm_index[i] -= 1; else ofdm_index[i] -= 2; } else if (txpwr_level[i] >= 32 && txpwr_level[i] <= 38 && thermalvalue > rtlefuse->eeprom_thermalmeter && delta > 5) { ofdm_index[i] -= 1; } } if (txpwr_level[i] >= 0 && txpwr_level[i] <= 26) { if (thermalvalue > rtlefuse->eeprom_thermalmeter) { if (delta < 5) cck_index -= 1; else cck_index -= 2; } else if (delta > 5 && thermalvalue < rtlefuse->eeprom_thermalmeter) { cck_index += 1; } } else if (txpwr_level[i] >= 27 && txpwr_level[i] <= 32 && thermalvalue > rtlefuse->eeprom_thermalmeter) { if (delta < 5) cck_index -= 1; else cck_index -= 2; } else if (txpwr_level[i] >= 32 && txpwr_level[i] <= 38 && thermalvalue > rtlefuse->eeprom_thermalmeter && delta > 5) { cck_index -= 1; } for (i = 0; i < rf; i++) { if (ofdm_index[i] > OFDM_TABLE_SIZE - 1) ofdm_index[i] = OFDM_TABLE_SIZE - 1; else if (ofdm_index[i] < ofdm_min_index) ofdm_index[i] = ofdm_min_index; } if (cck_index > CCK_TABLE_SIZE - 1) cck_index = CCK_TABLE_SIZE - 1; else if (cck_index < 0) cck_index = 0; if (is2t) { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "new OFDM_A_index=0x%x, OFDM_B_index=0x%x, cck_index=0x%x\n", ofdm_index[0], ofdm_index[1], cck_index); } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "new OFDM_A_index=0x%x, cck_index=0x%x\n", ofdm_index[0], cck_index); } } if (rtlpriv->dm.<API key> && delta != 0) { ele_d = (ofdmswing_table[ofdm_index[0]] & 0xFFC00000) >> 22; val_x = rtlphy->reg_e94; val_y = rtlphy->reg_e9c; if (val_x != 0) { if ((val_x & 0x00000200) != 0) val_x = val_x | 0xFFFFFC00; ele_a = ((val_x * ele_d) >> 8) & 0x000003FF; if ((val_y & 0x00000200) != 0) val_y = val_y | 0xFFFFFC00; ele_c = ((val_y * ele_d) >> 8) & 0x000003FF; value32 = (ele_d << 22) | ((ele_c & 0x3F) << 16) | ele_a; rtl_set_bbreg(hw, <API key>, MASKDWORD, value32); value32 = (ele_c & 0x000003C0) >> 6; rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, value32); value32 = ((val_x * ele_d) >> 7) & 0x01; rtl_set_bbreg(hw, <API key>, BIT(31), value32); value32 = ((val_y * ele_d) >> 7) & 0x01; rtl_set_bbreg(hw, <API key>, BIT(29), value32); } else { rtl_set_bbreg(hw, <API key>, MASKDWORD, ofdmswing_table[ofdm_index[0]]); rtl_set_bbreg(hw, ROFDM0_XCTXAFE, MASKH4BITS, 0x00); rtl_set_bbreg(hw, <API key>, BIT(31) | BIT(29), 0x00); } if (!rtlpriv->dm.cck_inch14) { rtl_write_byte(rtlpriv, 0xa22, <API key>[cck_index] [0]); rtl_write_byte(rtlpriv, 0xa23, <API key>[cck_index] [1]); rtl_write_byte(rtlpriv, 0xa24, <API key>[cck_index] [2]); rtl_write_byte(rtlpriv, 0xa25, <API key>[cck_index] [3]); rtl_write_byte(rtlpriv, 0xa26, <API key>[cck_index] [4]); rtl_write_byte(rtlpriv, 0xa27, <API key>[cck_index] [5]); rtl_write_byte(rtlpriv, 0xa28, <API key>[cck_index] [6]); rtl_write_byte(rtlpriv, 0xa29, <API key>[cck_index] [7]); } else { rtl_write_byte(rtlpriv, 0xa22, cckswing_table_ch14[cck_index] [0]); rtl_write_byte(rtlpriv, 0xa23, cckswing_table_ch14[cck_index] [1]); rtl_write_byte(rtlpriv, 0xa24, cckswing_table_ch14[cck_index] [2]); rtl_write_byte(rtlpriv, 0xa25, cckswing_table_ch14[cck_index] [3]); rtl_write_byte(rtlpriv, 0xa26, cckswing_table_ch14[cck_index] [4]); rtl_write_byte(rtlpriv, 0xa27, cckswing_table_ch14[cck_index] [5]); rtl_write_byte(rtlpriv, 0xa28, cckswing_table_ch14[cck_index] [6]); rtl_write_byte(rtlpriv, 0xa29, cckswing_table_ch14[cck_index] [7]); } if (is2t) { ele_d = (ofdmswing_table[ofdm_index[1]] & 0xFFC00000) >> 22; val_x = rtlphy->reg_eb4; val_y = rtlphy->reg_ebc; if (val_x != 0) { if ((val_x & 0x00000200) != 0) val_x = val_x | 0xFFFFFC00; ele_a = ((val_x * ele_d) >> 8) & 0x000003FF; if ((val_y & 0x00000200) != 0) val_y = val_y | 0xFFFFFC00; ele_c = ((val_y * ele_d) >> 8) & 0x00003FF; value32 = (ele_d << 22) | ((ele_c & 0x3F) << 16) | ele_a; rtl_set_bbreg(hw, <API key>, MASKDWORD, value32); value32 = (ele_c & 0x000003C0) >> 6; rtl_set_bbreg(hw, ROFDM0_XDTXAFE, MASKH4BITS, value32); value32 = ((val_x * ele_d) >> 7) & 0x01; rtl_set_bbreg(hw, <API key>, BIT(27), value32); value32 = ((val_y * ele_d) >> 7) & 0x01; rtl_set_bbreg(hw, <API key>, BIT(25), value32); } else { rtl_set_bbreg(hw, <API key>, MASKDWORD, ofdmswing_table[ofdm_index [1]]); rtl_set_bbreg(hw, ROFDM0_XDTXAFE, MASKH4BITS, 0x00); rtl_set_bbreg(hw, <API key>, BIT(27) | BIT(25), 0x00); } } } if (delta_iqk > 3) { rtlpriv->dm.thermalvalue_iqk = thermalvalue; <API key>(hw, false); } if (rtlpriv->dm.<API key>) rtlpriv->dm.thermalvalue = thermalvalue; } RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===\n"); } static void <API key>( struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); rtlpriv->dm.txpower_tracking = true; rtlpriv->dm.<API key> = false; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "pMgntInfo->txpower_tracking = %d\n", rtlpriv->dm.txpower_tracking); } static void <API key>(struct ieee80211_hw *hw) { <API key>(hw); } static void <API key>(struct ieee80211_hw *hw) { <API key>(hw); } static void <API key>( struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); if (!rtlpriv->dm.txpower_tracking) return; if (!rtlpriv->dm.tm_trigger) { rtl_set_rfreg(hw, RF90_PATH_A, RF_T_METER, RFREG_OFFSET_MASK, 0x60); RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Trigger 92S Thermal Meter!!\n"); rtlpriv->dm.tm_trigger = 1; return; } else { RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "Schedule TxPowerTracking direct call!!\n"); <API key>(hw); rtlpriv->dm.tm_trigger = 0; } } void <API key>(struct ieee80211_hw *hw) { <API key>(hw); } EXPORT_SYMBOL(<API key>); void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rate_adaptive *p_ra = &(rtlpriv->ra); p_ra->ratr_state = DM_RATR_STA_INIT; p_ra->pre_ratr_state = DM_RATR_STA_INIT; if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) rtlpriv->dm.useramask = true; else rtlpriv->dm.useramask = false; } EXPORT_SYMBOL(<API key>); static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct ps_t *dm_pstable = &rtlpriv->dm_pstable; dm_pstable->pre_ccastate = CCA_MAX; dm_pstable->cur_ccasate = CCA_MAX; dm_pstable->pre_rfstate = RF_MAX; dm_pstable->cur_rfstate = RF_MAX; dm_pstable->rssi_val_min = 0; } void rtl92c_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct ps_t *dm_pstable = &rtlpriv->dm_pstable; if (!rtlpriv->reg_init) { rtlpriv->reg_874 = (rtl_get_bbreg(hw, <API key>, MASKDWORD) & 0x1CC000) >> 14; rtlpriv->reg_c70 = (rtl_get_bbreg(hw, <API key>, MASKDWORD) & BIT(3)) >> 3; rtlpriv->reg_85c = (rtl_get_bbreg(hw, <API key>, MASKDWORD) & 0xFF000000) >> 24; rtlpriv->reg_a74 = (rtl_get_bbreg(hw, 0xa74, MASKDWORD) & 0xF000) >> 12; rtlpriv->reg_init = true; } if (!bforce_in_normal) { if (dm_pstable->rssi_val_min != 0) { if (dm_pstable->pre_rfstate == RF_NORMAL) { if (dm_pstable->rssi_val_min >= 30) dm_pstable->cur_rfstate = RF_SAVE; else dm_pstable->cur_rfstate = RF_NORMAL; } else { if (dm_pstable->rssi_val_min <= 25) dm_pstable->cur_rfstate = RF_NORMAL; else dm_pstable->cur_rfstate = RF_SAVE; } } else { dm_pstable->cur_rfstate = RF_MAX; } } else { dm_pstable->cur_rfstate = RF_NORMAL; } if (dm_pstable->pre_rfstate != dm_pstable->cur_rfstate) { if (dm_pstable->cur_rfstate == RF_SAVE) { rtl_set_bbreg(hw, <API key>, 0x1C0000, 0x2); rtl_set_bbreg(hw, <API key>, BIT(3), 0); rtl_set_bbreg(hw, <API key>, 0xFF000000, 0x63); rtl_set_bbreg(hw, <API key>, 0xC000, 0x2); rtl_set_bbreg(hw, 0xa74, 0xF000, 0x3); rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); rtl_set_bbreg(hw, 0x818, BIT(28), 0x1); } else { rtl_set_bbreg(hw, <API key>, 0x1CC000, rtlpriv->reg_874); rtl_set_bbreg(hw, <API key>, BIT(3), rtlpriv->reg_c70); rtl_set_bbreg(hw, <API key>, 0xFF000000, rtlpriv->reg_85c); rtl_set_bbreg(hw, 0xa74, 0xF000, rtlpriv->reg_a74); rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); } dm_pstable->pre_rfstate = dm_pstable->cur_rfstate; } } EXPORT_SYMBOL(rtl92c_dm_rf_saving); static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct ps_t *dm_pstable = &rtlpriv->dm_pstable; struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); /* Determine the minimum RSSI */ if (((mac->link_state == MAC80211_NOLINK)) && (rtlpriv->dm.<API key> == 0)) { dm_pstable->rssi_val_min = 0; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "Not connected to any\n"); } if (mac->link_state == MAC80211_LINKED) { if (mac->opmode == <API key>) { dm_pstable->rssi_val_min = rtlpriv->dm.<API key>; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "AP Client PWDB = 0x%lx\n", dm_pstable->rssi_val_min); } else { dm_pstable->rssi_val_min = rtlpriv->dm.undec_sm_pwdb; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "STA Default Port PWDB = 0x%lx\n", dm_pstable->rssi_val_min); } } else { dm_pstable->rssi_val_min = rtlpriv->dm.<API key>; RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, "AP Ext Port PWDB = 0x%lx\n", dm_pstable->rssi_val_min); } /* Power Saving for 92C */ if (IS_92C_SERIAL(rtlhal->version)) ;/* rtl92c_dm_1r_cca(hw); */ else rtl92c_dm_rf_saving(hw, false); } void rtl92c_dm_init(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER; rtlpriv->dm.dm_flag = <API key> | DYNAMIC_FUNC_DIG; rtlpriv->dm.undec_sm_pwdb = -1; rtlpriv->dm.undec_sm_cck = -1; rtlpriv->dm.<API key> = true; rtl_dm_diginit(hw, 0x20); rtlpriv->dm.dm_flag |= <API key>; <API key>(hw); <API key>(hw); <API key>(hw); rtlpriv->dm.dm_flag |= DYNAMIC_FUNC_SS; <API key>(hw); <API key>(hw); rtlpriv->dm.ofdm_pkt_cnt = 0; rtlpriv->dm.dm_rssi_sel = RSSI_DEFAULT; } EXPORT_SYMBOL(rtl92c_dm_init); void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); long undec_sm_pwdb; if (!rtlpriv->dm.<API key>) return; if (rtlpriv->dm.dm_flag & <API key>) { rtlpriv->dm.<API key> = <API key>; return; } if ((mac->link_state < MAC80211_LINKED) && (rtlpriv->dm.<API key> == 0)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, "Not connected to any\n"); rtlpriv->dm.<API key> = <API key>; rtlpriv->dm.last_dtp_lvl = <API key>; return; } if (mac->link_state >= MAC80211_LINKED) { if (mac->opmode == <API key>) { undec_sm_pwdb = rtlpriv->dm.<API key>; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "AP Client PWDB = 0x%lx\n", undec_sm_pwdb); } else { undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "STA Default Port PWDB = 0x%lx\n", undec_sm_pwdb); } } else { undec_sm_pwdb = rtlpriv->dm.<API key>; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "AP Ext Port PWDB = 0x%lx\n", undec_sm_pwdb); } if (undec_sm_pwdb >= <API key>) { rtlpriv->dm.<API key> = <API key>; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "<API key> (TxPwr=0x0)\n"); } else if ((undec_sm_pwdb < (<API key> - 3)) && (undec_sm_pwdb >= <API key>)) { rtlpriv->dm.<API key> = <API key>; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "<API key> (TxPwr=0x10)\n"); } else if (undec_sm_pwdb < (<API key> - 5)) { rtlpriv->dm.<API key> = <API key>; RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "<API key>\n"); } if ((rtlpriv->dm.<API key> != rtlpriv->dm.last_dtp_lvl)) { RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "<API key>() Channel = %d\n", rtlphy->current_channel); <API key>(hw, rtlphy->current_channel); if (rtlpriv->dm.<API key> == <API key>) <API key>(hw); else if (rtlpriv->dm.<API key> == <API key>) dm_writepowerindex(hw, 0x14); else if (rtlpriv->dm.<API key> == <API key>) dm_writepowerindex(hw, 0x10); } rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.<API key>; } void rtl92c_dm_watchdog(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); bool fw_current_inpsmode = false; bool fw_ps_awake = true; rtlpriv->cfg->ops->get_hw_reg(hw, <API key>, (u8 *) (&fw_current_inpsmode)); rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON, (u8 *) (&fw_ps_awake)); if (ppsc->p2p_ps_info.p2p_ps_mode) fw_ps_awake = false; if ((ppsc->rfpwr_state == ERFON) && ((!fw_current_inpsmode) && fw_ps_awake) && (!ppsc->rfchange_inprogress)) { <API key>(hw); rtl92c_dm_dig(hw); <API key>(hw); <API key>(hw); <API key>(hw); <API key>(hw); /* <API key>(hw); */ <API key>(hw); <API key>(hw); } } EXPORT_SYMBOL(rtl92c_dm_watchdog); u8 <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); long undec_sm_pwdb; u8 curr_bt_rssi_state = 0x00; if (rtlpriv->mac80211.link_state == MAC80211_LINKED) { undec_sm_pwdb = <API key>(rtlpriv); } else { if (rtlpriv->dm.<API key> == 0) undec_sm_pwdb = 100; else undec_sm_pwdb = rtlpriv->dm.<API key>; } /* Check RSSI to determine HighPower/NormalPower state for * BT coexistence. */ if (undec_sm_pwdb >= 67) curr_bt_rssi_state &= (~<API key>); else if (undec_sm_pwdb < 62) curr_bt_rssi_state |= <API key>; /* Check RSSI to determine AMPDU setting for BT coexistence. */ if (undec_sm_pwdb >= 40) curr_bt_rssi_state &= (~<API key>); else if (undec_sm_pwdb <= 32) curr_bt_rssi_state |= <API key>; /* Marked RSSI state. It will be used to determine BT coexistence * setting later. */ if (undec_sm_pwdb < 35) curr_bt_rssi_state |= <API key>; else curr_bt_rssi_state &= (~<API key>); /* Check BT state related to BT_Idle in B/G mode. */ if (undec_sm_pwdb < 15) curr_bt_rssi_state |= <API key>; else curr_bt_rssi_state &= (~<API key>); if (curr_bt_rssi_state != rtlpriv->btcoexist.bt_rssi_state) { rtlpriv->btcoexist.bt_rssi_state = curr_bt_rssi_state; return true; } else { return false; } } EXPORT_SYMBOL(<API key>); static bool <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); u32 polling, ratio_tx, ratio_pri; u32 bt_tx, bt_pri; u8 bt_state; u8 cur_service_type; if (rtlpriv->mac80211.link_state < MAC80211_LINKED) return false; bt_state = rtl_read_byte(rtlpriv, 0x4fd); bt_tx = rtl_read_dword(rtlpriv, 0x488) & BT_MASK; bt_pri = rtl_read_dword(rtlpriv, 0x48c) & BT_MASK; polling = rtl_read_dword(rtlpriv, 0x490); if (bt_tx == BT_MASK && bt_pri == BT_MASK && polling == 0xffffffff && bt_state == 0xff) return false; bt_state &= <API key>(0, 1); if (bt_state != rtlpriv->btcoexist.bt_cur_state) { rtlpriv->btcoexist.bt_cur_state = bt_state; if (rtlpriv->btcoexist.reg_bt_sco == 3) { rtlpriv->btcoexist.bt_service = BT_IDLE; bt_state = bt_state | ((rtlpriv->btcoexist.bt_ant_isolation == 1) ? 0 : <API key>(1, 1)) | <API key>(2, 1); rtl_write_byte(rtlpriv, 0x4fd, bt_state); } return true; } ratio_tx = bt_tx * 1000 / polling; ratio_pri = bt_pri * 1000 / polling; rtlpriv->btcoexist.ratio_tx = ratio_tx; rtlpriv->btcoexist.ratio_pri = ratio_pri; if (bt_state && rtlpriv->btcoexist.reg_bt_sco == 3) { if ((ratio_tx < 30) && (ratio_pri < 30)) cur_service_type = BT_IDLE; else if ((ratio_pri > 110) && (ratio_pri < 250)) cur_service_type = BT_SCO; else if ((ratio_tx >= 200) && (ratio_pri >= 200)) cur_service_type = BT_BUSY; else if ((ratio_tx >= 350) && (ratio_tx < 500)) cur_service_type = BT_OTHERBUSY; else if (ratio_tx >= 500) cur_service_type = BT_PAN; else cur_service_type = BT_OTHER_ACTION; if (cur_service_type != rtlpriv->btcoexist.bt_service) { rtlpriv->btcoexist.bt_service = cur_service_type; bt_state = bt_state | ((rtlpriv->btcoexist.bt_ant_isolation == 1) ? 0 : <API key>(1, 1)) | ((rtlpriv->btcoexist.bt_service != BT_IDLE) ? 0 : <API key>(2, 1)); /* Add interrupt migration when bt is not ini * idle state (no traffic). */ if (rtlpriv->btcoexist.bt_service != BT_IDLE) { rtl_write_word(rtlpriv, 0x504, 0x0ccc); rtl_write_byte(rtlpriv, 0x506, 0x54); rtl_write_byte(rtlpriv, 0x507, 0x54); } else { rtl_write_byte(rtlpriv, 0x506, 0x00); rtl_write_byte(rtlpriv, 0x507, 0x00); } rtl_write_byte(rtlpriv, 0x4fd, bt_state); return true; } } return false; } static bool <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); static bool media_connect; if (rtlpriv->mac80211.link_state < MAC80211_LINKED) { media_connect = false; } else { if (!media_connect) { media_connect = true; return true; } media_connect = true; } return false; } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); if (rtlpriv->btcoexist.bt_service == BT_OTHERBUSY) { rtlpriv->btcoexist.bt_edca_ul = 0x5ea72b; rtlpriv->btcoexist.bt_edca_dl = 0x5ea72b; } else if (rtlpriv->btcoexist.bt_service == BT_BUSY) { rtlpriv->btcoexist.bt_edca_ul = 0x5eb82f; rtlpriv->btcoexist.bt_edca_dl = 0x5eb82f; } else if (rtlpriv->btcoexist.bt_service == BT_SCO) { if (rtlpriv->btcoexist.ratio_tx > 160) { rtlpriv->btcoexist.bt_edca_ul = 0x5ea72f; rtlpriv->btcoexist.bt_edca_dl = 0x5ea72f; } else { rtlpriv->btcoexist.bt_edca_ul = 0x5ea32b; rtlpriv->btcoexist.bt_edca_dl = 0x5ea42b; } } else { rtlpriv->btcoexist.bt_edca_ul = 0; rtlpriv->btcoexist.bt_edca_dl = 0; } if ((rtlpriv->btcoexist.bt_service != BT_IDLE) && (rtlpriv->mac80211.mode == WIRELESS_MODE_G || (rtlpriv->mac80211.mode == (WIRELESS_MODE_G | WIRELESS_MODE_B))) && (rtlpriv->btcoexist.bt_rssi_state & <API key>)) { rtlpriv->btcoexist.bt_edca_ul = 0x5eb82b; rtlpriv->btcoexist.bt_edca_dl = 0x5eb82b; } } static void <API key>(struct ieee80211_hw *hw, u8 tmp1byte) { struct rtl_priv *rtlpriv = rtl_priv(hw); /* Only enable HW BT coexist when BT in "Busy" state. */ if (rtlpriv->mac80211.vendor == PEER_CISCO && rtlpriv->btcoexist.bt_service == BT_OTHER_ACTION) { rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0); } else { if ((rtlpriv->btcoexist.bt_service == BT_BUSY) && (rtlpriv->btcoexist.bt_rssi_state & <API key>)) { rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0); } else if ((rtlpriv->btcoexist.bt_service == BT_OTHER_ACTION) && (rtlpriv->mac80211.mode < WIRELESS_MODE_N_24G) && (rtlpriv->btcoexist.bt_rssi_state & <API key>)) { rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, 0xa0); } else { rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, tmp1byte); } } if (rtlpriv->btcoexist.bt_service == BT_PAN) rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, 0x10100); else rtl_write_dword(rtlpriv, REG_GPIO_PIN_CTRL, 0x0); if (rtlpriv->btcoexist.bt_rssi_state & <API key>) { <API key>(hw); } else { rtlpriv->btcoexist.bt_edca_ul = 0; rtlpriv->btcoexist.bt_edca_dl = 0; } if (rtlpriv->btcoexist.bt_service != BT_IDLE) { rtlpriv->cfg->ops->set_rfreg(hw, RF90_PATH_A, 0x1e, 0xf0, 0xf); } else { rtlpriv->cfg->ops->set_rfreg(hw, RF90_PATH_A, 0x1e, 0xf0, rtlpriv->btcoexist.bt_rfreg_origin_1e); } if (!rtlpriv->dm.<API key>) { if (rtlpriv->btcoexist.bt_service != BT_IDLE) { if (rtlpriv->btcoexist.bt_rssi_state & <API key>) { rtlpriv->dm.<API key> = TXHIGHPWRLEVEL_BT2; } else { rtlpriv->dm.<API key> = TXHIGHPWRLEVEL_BT1; } } else { rtlpriv->dm.<API key> = <API key>; } <API key>(hw, rtlpriv->phy.current_channel); } } static void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); u8 tmp1byte = 0; if (<API key>(rtlhal->version) && rtlpriv->btcoexist.bt_coexistence) tmp1byte |= BIT(5); if (rtlpriv->btcoexist.bt_cur_state) { if (rtlpriv->btcoexist.bt_ant_isolation) <API key>(hw, tmp1byte); } else { rtl_write_byte(rtlpriv, REG_GPIO_MUXCFG, tmp1byte); rtlpriv->cfg->ops->set_rfreg(hw, RF90_PATH_A, 0x1e, 0xf0, rtlpriv->btcoexist.bt_rfreg_origin_1e); rtlpriv->btcoexist.bt_edca_ul = 0; rtlpriv->btcoexist.bt_edca_dl = 0; } } void <API key>(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); bool wifi_connect_change; bool bt_state_change; bool rssi_state_change; if ((rtlpriv->btcoexist.bt_coexistence) && (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4)) { wifi_connect_change = <API key>(hw); bt_state_change = <API key>(hw); rssi_state_change = <API key>(hw); if (wifi_connect_change || bt_state_change || rssi_state_change) <API key>(hw); } } EXPORT_SYMBOL(<API key>);
#ifndef _LIBFC_H_ #define _LIBFC_H_ #include <linux/timer.h> #include <linux/if.h> #include <linux/percpu.h> #include <scsi/scsi_transport.h> #include <scsi/scsi_transport_fc.h> #include <scsi/scsi_bsg_fc.h> #include <scsi/fc/fc_fcp.h> #include <scsi/fc/fc_ns.h> #include <scsi/fc/fc_ms.h> #include <scsi/fc/fc_els.h> #include <scsi/fc/fc_gs.h> #include <scsi/fc_frame.h> #define FC_FC4_PROV_SIZE (FC_TYPE_FCP + 1) #define FC_NO_ERR 0 #define FC_EX_TIMEOUT 1 #define FC_EX_CLOSED 2 enum fc_lport_state { LPORT_ST_DISABLED = 0, LPORT_ST_FLOGI, LPORT_ST_DNS, LPORT_ST_RNN_ID, LPORT_ST_RSNN_NN, LPORT_ST_RSPN_ID, LPORT_ST_RFT_ID, LPORT_ST_RFF_ID, LPORT_ST_FDMI, LPORT_ST_RHBA, LPORT_ST_RPA, LPORT_ST_DHBA, LPORT_ST_DPRT, LPORT_ST_SCR, LPORT_ST_READY, LPORT_ST_LOGO, LPORT_ST_RESET }; enum fc_disc_event { DISC_EV_NONE = 0, DISC_EV_SUCCESS, DISC_EV_FAILED }; enum fc_rport_state { RPORT_ST_INIT, RPORT_ST_FLOGI, RPORT_ST_PLOGI_WAIT, RPORT_ST_PLOGI, RPORT_ST_PRLI, RPORT_ST_RTV, RPORT_ST_READY, RPORT_ST_ADISC, RPORT_ST_DELETE, }; struct fc_disc_port { struct fc_lport *lp; struct list_head peers; struct work_struct rport_work; u32 port_id; }; enum fc_rport_event { RPORT_EV_NONE = 0, RPORT_EV_READY, RPORT_EV_FAILED, RPORT_EV_STOP, RPORT_EV_LOGO }; struct fc_rport_priv; struct fc_rport_operations { void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event); }; struct fc_rport_libfc_priv { struct fc_lport *local_port; enum fc_rport_state rp_state; u16 flags; #define <API key> (1 << 0) #define FC_RP_FLAGS_RETRY (1 << 1) #define FC_RP_STARTED (1 << 2) #define <API key> (1 << 3) unsigned int e_d_tov; unsigned int r_a_tov; }; struct fc_rport_priv { struct fc_lport *local_port; struct fc_rport *rport; struct kref kref; enum fc_rport_state rp_state; struct <API key> ids; u16 flags; u16 max_seq; u16 disc_id; u16 maxframe_size; unsigned int retries; unsigned int major_retries; unsigned int e_d_tov; unsigned int r_a_tov; struct mutex rp_mutex; struct delayed_work retry_work; enum fc_rport_event event; struct fc_rport_operations *ops; struct list_head peers; struct work_struct event_work; u32 supported_classes; u16 prli_count; struct rcu_head rcu; u16 sp_features; u8 spp_type; void (*lld_event_callback)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event); }; struct fcoe_dev_stats { u64 <API key>; u64 TxFrames; u64 TxWords; u64 RxFrames; u64 RxWords; u64 ErrorFrames; u64 DumpedFrames; u64 LinkFailureCount; u64 LossOfSignalCount; u64 InvalidTxWordCount; u64 InvalidCRCCount; u64 InputRequests; u64 OutputRequests; u64 ControlRequests; u64 InputBytes; u64 OutputBytes; u64 VLinkFailureCount; u64 MissDiscAdvCount; }; struct fc_seq_els_data { enum fc_els_rjt_reason reason; enum fc_els_rjt_explan explan; }; struct fc_fcp_pkt { spinlock_t scsi_pkt_lock; atomic_t ref_cnt; u32 data_len; struct scsi_cmnd *cmd; struct list_head list; struct fc_lport *lp; u8 state; u8 cdb_status; u8 status_code; u8 scsi_comp_flags; u32 io_status; u32 req_flags; u32 scsi_resid; size_t xfer_len; struct fcp_cmnd cdb_cmd; u32 xfer_contig_end; u16 max_payload; u16 xfer_ddp; struct fc_rport *rport; struct fc_seq *seq_ptr; struct timer_list timer; int wait_for_comp; u32 recov_retry; struct fc_seq *recov_seq; struct completion tm_done; } <API key>; struct fc_exch_mgr; struct fc_exch_mgr_anchor; extern u16 fc_cpu_mask; struct fc_seq { u8 id; u16 ssb_stat; u16 cnt; u32 rec_data; }; #define FC_EX_DONE (1 << 0) #define FC_EX_RST_CLEANUP (1 << 1) struct fc_exch { spinlock_t ex_lock; atomic_t ex_refcnt; enum fc_class class; struct fc_exch_mgr *em; struct fc_exch_pool *pool; struct list_head ex_list; struct fc_lport *lp; u32 esb_stat; u8 state; u8 fh_type; u8 seq_id; u8 encaps; u16 xid; u16 oxid; u16 rxid; u32 oid; u32 sid; u32 did; u32 r_a_tov; u32 f_ctl; struct fc_seq seq; void (*resp)(struct fc_seq *, struct fc_frame *, void *); void *arg; void (*destructor)(struct fc_seq *, void *); struct delayed_work timeout_work; } <API key>; #define fc_seq_exch(sp) container_of(sp, struct fc_exch, seq) struct <API key> { int (*frame_send)(struct fc_lport *, struct fc_frame *); struct fc_seq *(*elsct_send)(struct fc_lport *, u32 did, struct fc_frame *, unsigned int op, void (*resp)(struct fc_seq *, struct fc_frame *, void *arg), void *arg, u32 timer_msec); struct fc_seq *(*exch_seq_send)(struct fc_lport *, struct fc_frame *, void (*resp)(struct fc_seq *, struct fc_frame *, void *), void (*destructor)(struct fc_seq *, void *), void *, unsigned int timer_msec); int (*ddp_setup)(struct fc_lport *, u16, struct scatterlist *, unsigned int); int (*ddp_done)(struct fc_lport *, u16); int (*ddp_target)(struct fc_lport *, u16, struct scatterlist *, unsigned int); void (*get_lesb)(struct fc_lport *, struct fc_els_lesb *lesb); int (*seq_send)(struct fc_lport *, struct fc_seq *, struct fc_frame *); void (*seq_els_rsp_send)(struct fc_frame *, enum fc_els_cmd, struct fc_seq_els_data *); int (*seq_exch_abort)(const struct fc_seq *, unsigned int timer_msec); void (*exch_done)(struct fc_seq *); struct fc_seq *(*seq_start_next)(struct fc_seq *); void (*seq_set_resp)(struct fc_seq *sp, void (*resp)(struct fc_seq *, struct fc_frame *, void *), void *arg); struct fc_seq *(*seq_assign)(struct fc_lport *, struct fc_frame *); void (*seq_release)(struct fc_seq *); void (*exch_mgr_reset)(struct fc_lport *, u32 s_id, u32 d_id); void (*rport_flush_queue)(void); void (*lport_recv)(struct fc_lport *, struct fc_frame *); int (*lport_reset)(struct fc_lport *); void (*lport_set_port_id)(struct fc_lport *, u32 port_id, struct fc_frame *); struct fc_rport_priv *(*rport_create)(struct fc_lport *, u32); int (*rport_login)(struct fc_rport_priv *); int (*rport_logoff)(struct fc_rport_priv *); void (*rport_recv_req)(struct fc_lport *, struct fc_frame *); struct fc_rport_priv *(*rport_lookup)(const struct fc_lport *, u32); void (*rport_destroy)(struct kref *); void (*<API key>)(struct fc_lport *, struct fc_rport_priv *, enum fc_rport_event); int (*fcp_cmd_send)(struct fc_lport *, struct fc_fcp_pkt *, void (*resp)(struct fc_seq *, struct fc_frame *, void *)); void (*fcp_cleanup)(struct fc_lport *); void (*fcp_abort_io)(struct fc_lport *); void (*disc_recv_req)(struct fc_lport *, struct fc_frame *); void (*disc_start)(void (*disc_callback)(struct fc_lport *, enum fc_disc_event), struct fc_lport *); void (*disc_stop) (struct fc_lport *); void (*disc_stop_final) (struct fc_lport *); }; struct fc_disc { unsigned char retry_count; unsigned char pending; unsigned char requested; unsigned short seq_count; unsigned char buf_len; u16 disc_id; struct list_head rports; void *priv; struct mutex disc_mutex; struct fc_gpn_ft_resp partial_buf; struct delayed_work disc_work; void (*disc_callback)(struct fc_lport *, enum fc_disc_event); }; extern struct <API key> <API key>; enum fc_lport_event { FC_LPORT_EV_ADD, FC_LPORT_EV_DEL, }; struct fc_lport { struct Scsi_Host *host; struct list_head ema_list; struct fc_rport_priv *dns_rdata; struct fc_rport_priv *ms_rdata; struct fc_rport_priv *ptp_rdata; void *scsi_priv; struct fc_disc disc; struct list_head vports; struct fc_vport *vport; struct <API key> tt; u8 link_up; u8 qfull; enum fc_lport_state state; unsigned long boot_time; struct fc_host_statistics host_stats; struct fcoe_dev_stats __percpu *dev_stats; u8 retry_count; u32 port_id; u64 wwpn; u64 wwnn; unsigned int service_params; unsigned int e_d_tov; unsigned int r_a_tov; struct fc_els_rnid_gen rnid_gen; u32 sg_supp:1; u32 seq_offload:1; u32 crc_offload:1; u32 lro_enabled:1; u32 does_npiv:1; u32 npiv_enabled:1; u32 point_to_multipoint:1; u32 fdmi_enabled:1; u32 mfs; u8 max_retry_count; u8 <API key>; u16 rport_priv_size; u16 link_speed; u16 <API key>; u16 lro_xid; unsigned int lso_max; struct fc_ns_fts fcts; struct mutex lp_mutex; struct list_head list; struct delayed_work retry_work; void *prov[FC_FC4_PROV_SIZE]; struct list_head lport_list; }; struct fc4_prov { int (*prli)(struct fc_rport_priv *, u32 spp_len, const struct fc_els_spp *spp_in, struct fc_els_spp *spp_out); void (*prlo)(struct fc_rport_priv *); void (*recv)(struct fc_lport *, struct fc_frame *); struct module *module; }; int <API key>(enum fc_fh_type type, struct fc4_prov *); void <API key>(enum fc_fh_type type, struct fc4_prov *); static inline int fc_lport_test_ready(struct fc_lport *lport) { return lport->state == LPORT_ST_READY; } static inline void fc_set_wwnn(struct fc_lport *lport, u64 wwnn) { lport->wwnn = wwnn; } static inline void fc_set_wwpn(struct fc_lport *lport, u64 wwnn) { lport->wwpn = wwnn; } static inline void <API key>(struct fc_lport *lport, enum fc_lport_state state) { if (state != lport->state) lport->retry_count = 0; lport->state = state; } static inline int fc_lport_init_stats(struct fc_lport *lport) { lport->dev_stats = alloc_percpu(struct fcoe_dev_stats); if (!lport->dev_stats) return -ENOMEM; return 0; } static inline void fc_lport_free_stats(struct fc_lport *lport) { free_percpu(lport->dev_stats); } static inline void *lport_priv(const struct fc_lport *lport) { return (void *)(lport + 1); } static inline struct fc_lport * libfc_host_alloc(struct scsi_host_template *sht, int priv_size) { struct fc_lport *lport; struct Scsi_Host *shost; shost = scsi_host_alloc(sht, sizeof(*lport) + priv_size); if (!shost) return NULL; lport = shost_priv(shost); lport->host = shost; INIT_LIST_HEAD(&lport->ema_list); INIT_LIST_HEAD(&lport->vports); return lport; } static inline bool fc_fcp_is_read(const struct fc_fcp_pkt *fsp) { if (fsp && fsp->cmd) return fsp->cmd->sc_data_direction == DMA_FROM_DEVICE; return false; } int fc_lport_init(struct fc_lport *); int fc_lport_destroy(struct fc_lport *); int fc_fabric_logoff(struct fc_lport *); int fc_fabric_login(struct fc_lport *); void __fc_linkup(struct fc_lport *); void fc_linkup(struct fc_lport *); void __fc_linkdown(struct fc_lport *); void fc_linkdown(struct fc_lport *); void fc_vport_setlink(struct fc_lport *); void <API key>(struct fc_lport *); int fc_lport_config(struct fc_lport *); int fc_lport_reset(struct fc_lport *); int fc_set_mfs(struct fc_lport *, u32 mfs); struct fc_lport *libfc_vport_create(struct fc_vport *, int privsize); struct fc_lport *fc_vport_id_lookup(struct fc_lport *, u32 port_id); int <API key>(struct fc_bsg_job *); void <API key>(struct fc_lport *, u32 port_id); void fc_lport_iterate(void (*func)(struct fc_lport *, void *), void *); int fc_rport_init(struct fc_lport *); void <API key>(struct fc_rport *); int fc_disc_init(struct fc_lport *); static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc) { return container_of(disc, struct fc_lport, disc); } int fc_fcp_init(struct fc_lport *); void fc_fcp_destroy(struct fc_lport *); int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); int fc_eh_abort(struct scsi_cmnd *); int fc_eh_device_reset(struct scsi_cmnd *); int fc_eh_host_reset(struct scsi_cmnd *); int fc_slave_alloc(struct scsi_device *); int <API key>(struct scsi_device *, int qdepth, int reason); int <API key>(struct scsi_device *, int tag_type); int fc_elsct_init(struct fc_lport *); struct fc_seq *fc_elsct_send(struct fc_lport *, u32 did, struct fc_frame *, unsigned int op, void (*resp)(struct fc_seq *, struct fc_frame *, void *arg), void *arg, u32 timer_msec); void fc_lport_flogi_resp(struct fc_seq *, struct fc_frame *, void *); void fc_lport_logo_resp(struct fc_seq *, struct fc_frame *, void *); void fc_fill_reply_hdr(struct fc_frame *, const struct fc_frame *, enum fc_rctl, u32 parm_offset); void fc_fill_hdr(struct fc_frame *, const struct fc_frame *, enum fc_rctl, u32 f_ctl, u16 seq_cnt, u32 parm_offset); int fc_exch_init(struct fc_lport *); struct fc_exch_mgr_anchor *fc_exch_mgr_add(struct fc_lport *, struct fc_exch_mgr *, bool (*match)(struct fc_frame *)); void fc_exch_mgr_del(struct fc_exch_mgr_anchor *); int <API key>(struct fc_lport *src, struct fc_lport *dst); struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *, enum fc_class class, u16 min_xid, u16 max_xid, bool (*match)(struct fc_frame *)); void fc_exch_mgr_free(struct fc_lport *); void fc_exch_recv(struct fc_lport *, struct fc_frame *); void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); void fc_get_host_speed(struct Scsi_Host *); void <API key>(struct Scsi_Host *); void <API key>(struct fc_rport *, u32 timeout); struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *); #endif
#include <linux/io.h> #include <mach/board.h> #include "mdss_hdmi_util.h" static struct <API key> <API key>[HDMI_VFRMT_MAX]; void <API key>(u32 mode) { struct <API key> *ret = NULL; DEV_DBG("%s: removing %s\n", __func__, <API key>(mode)); ret = &<API key>[mode]; if (ret != NULL && ret->supported) ret->supported = false; } const struct <API key> *<API key>(u32 mode) { const struct <API key> *ret = NULL; if (mode >= HDMI_VFRMT_MAX) return NULL; ret = &<API key>[mode]; if (ret == NULL || !ret->supported) return NULL; return ret; } /* <API key> */ int <API key>(struct <API key> *timing_in) { int i, vic = -1; if (!timing_in) { DEV_ERR("%s: invalid input\n", __func__); goto exit; } /* active_low_h, active_low_v and interlaced are not checked against */ for (i = 0; i < HDMI_VFRMT_MAX; i++) { struct <API key> *supported_timing = &<API key>[i]; if (!supported_timing->supported) continue; if (timing_in->active_h != supported_timing->active_h) continue; if (timing_in->front_porch_h != supported_timing->front_porch_h) continue; if (timing_in->pulse_width_h != supported_timing->pulse_width_h) continue; if (timing_in->back_porch_h != supported_timing->back_porch_h) continue; if (timing_in->active_v != supported_timing->active_v) continue; if (timing_in->front_porch_v != supported_timing->front_porch_v) continue; if (timing_in->pulse_width_v != supported_timing->pulse_width_v) continue; if (timing_in->back_porch_v != supported_timing->back_porch_v) continue; if (timing_in->pixel_freq != supported_timing->pixel_freq) continue; if (timing_in->refresh_rate != supported_timing->refresh_rate) continue; vic = (int)supported_timing->video_format; break; } if (vic < 0) DEV_ERR("%s: timing asked is not yet supported\n", __func__); exit: DEV_DBG("%s: vic = %d timing = %s\n", __func__, vic, <API key>((u32)vic)); return vic; } /* <API key> */ /* Table indicating the video format supported by the HDMI TX Core */ /* Valid pclk rates (Mhz): 25.2, 27, 27.03, 74.25, 148.5, 268.5, 297 */ void <API key>(void) { <API key>(<API key>); /* Add all supported CEA modes to the lut */ <API key>( <API key>, MSM_HDMI_MODES_CEA); /*LGE_CHANGE : Disable Not-Supported Timing by anx7808*/ /* Add all supported extended hdmi modes to the lut */ /*<API key>( <API key>, MSM_HDMI_MODES_XTND);*/ /* Add any other specific DVI timings (DVI modes, etc.) */ <API key>( <API key>, MSM_HDMI_MODES_DVI); } /* <API key> */ const char *<API key>(u32 format) { switch (format) { case TOP_AND_BOTTOM: return "TAB"; case FRAME_PACKING: return "FP"; case SIDE_BY_SIDE_HALF: return "SSH"; } return ""; } /* <API key> */ ssize_t <API key>(u32 format, char *buf, u32 size) { ssize_t ret, len = 0; ret = scnprintf(buf, size, "%s", <API key>( format & FRAME_PACKING)); len += ret; if (len && (format & TOP_AND_BOTTOM)) ret = scnprintf(buf + len, size - len, ":%s", <API key>( format & TOP_AND_BOTTOM)); else ret = scnprintf(buf + len, size - len, "%s", <API key>( format & TOP_AND_BOTTOM)); len += ret; if (len && (format & SIDE_BY_SIDE_HALF)) ret = scnprintf(buf + len, size - len, ":%s", <API key>( format & SIDE_BY_SIDE_HALF)); else ret = scnprintf(buf + len, size - len, "%s", <API key>( format & SIDE_BY_SIDE_HALF)); len += ret; return len; } /* <API key> */ static void hdmi_ddc_print_data(struct hdmi_tx_ddc_data *ddc_data, const char *caller) { if (!ddc_data) { DEV_ERR("%s: invalid input\n", __func__); return; } DEV_DBG("%s: buf=%p, d_len=0x%x, d_addr=0x%x, no_align=%d\n", caller, ddc_data->data_buf, ddc_data->data_len, ddc_data->dev_addr, ddc_data->no_align); DEV_DBG("%s: offset=0x%x, req_len=0x%x, retry=%d, what=%s\n", caller, ddc_data->offset, ddc_data->request_len, ddc_data->retry, ddc_data->what); } /* hdmi_ddc_print_data */ static int hdmi_ddc_clear_irq(struct hdmi_tx_ddc_ctrl *ddc_ctrl, char *what) { u32 reg_val, time_out_count; if (!ddc_ctrl || !ddc_ctrl->io) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } /* clear pending and enable interrupt */ time_out_count = 0xFFFF; do { --time_out_count; /* Clear and Enable DDC interrupt */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL, BIT(2) | BIT(1)); reg_val = DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL); } while ((reg_val & BIT(0)) && time_out_count); if (!time_out_count) { DEV_ERR("%s[%s]: timedout\n", __func__, what); return -ETIMEDOUT; } return 0; } /*hdmi_ddc_clear_irq */ static int hdmi_ddc_read_retry(struct hdmi_tx_ddc_ctrl *ddc_ctrl, struct hdmi_tx_ddc_data *ddc_data) { u32 reg_val, ndx, time_out_count; int status = 0; int log_retry_fail; if (!ddc_ctrl || !ddc_ctrl->io || !ddc_data) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } if (!ddc_data->data_buf) { status = -EINVAL; DEV_ERR("%s[%s]: invalid buf\n", __func__, ddc_data->what); goto error; } hdmi_ddc_print_data(ddc_data, __func__); log_retry_fail = ddc_data->retry != 1; again: status = hdmi_ddc_clear_irq(ddc_ctrl, ddc_data->what); if (status) goto error; /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ ddc_data->dev_addr &= 0xFE; /* * 1. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #1 * DATA_RW = 0x0 (write) * DATA = linkAddress (primary link address and writing) * INDEX = 0x0 (initial offset into buffer) * INDEX_WRITE = 0x1 (setting initial offset) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, BIT(31) | (ddc_data->dev_addr << 8)); /* * 2. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #2 * DATA_RW = 0x0 (write) * DATA = offsetAddress * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, ddc_data->offset << 8); /* * 3. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #3 * DATA_RW = 0x0 (write) * DATA = linkAddress + 1 (primary link address 0x74 and reading) * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, (ddc_data->dev_addr | BIT(0)) << 8); /* Data setup is complete, now setup the transaction characteristics */ /* * 4. Write to <API key> with the following fields set in * order to handle characteristics of portion #1 and portion #2 * RW0 = 0x0 (write) * START0 = 0x1 (insert START bit) * STOP0 = 0x0 (do NOT insert STOP bit) * CNT0 = 0x1 (single byte transaction excluding address) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS0, BIT(12) | BIT(16)); /* * 5. Write to <API key> with the following fields set in * order to handle characteristics of portion #3 * RW1 = 0x1 (read) * START1 = 0x1 (insert START bit) * STOP1 = 0x1 (insert STOP bit) * CNT1 = data_len (it's 128 (0x80) for a blk read) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS1, BIT(0) | BIT(12) | BIT(13) | (ddc_data->request_len << 16)); /* Trigger the I2C transfer */ /* * 6. Write to HDMI_I2C_CONTROL to kick off the hardware. * Note that NOTHING has been transmitted on the DDC lines up to this * point. * TRANSACTION_CNT = 0x1 (execute transaction0 followed by * transaction1) * SEND_RESET = Set to 1 to send reset sequence * GO = 0x1 (kicks off hardware) */ INIT_COMPLETION(ddc_ctrl->ddc_sw_done); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(0) | BIT(20)); time_out_count = <API key>( &ddc_ctrl->ddc_sw_done, HZ/2); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL, BIT(1)); if (!time_out_count) { if (ddc_data->retry DEV_INFO("%s: failed timout, retry=%d\n", __func__, ddc_data->retry); goto again; } status = -ETIMEDOUT; DEV_ERR("%s: timedout(7), Int Ctrl=%08x\n", __func__, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_INT_CTRL)); DEV_ERR("%s: DDC SW Status=%08x, HW Status=%08x\n", __func__, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_SW_STATUS), DSS_REG_R(ddc_ctrl->io, HDMI_DDC_HW_STATUS)); goto error; } /* Read DDC status */ reg_val = DSS_REG_R(ddc_ctrl->io, HDMI_DDC_SW_STATUS); reg_val &= BIT(12) | BIT(13) | BIT(14) | BIT(15); /* Check if any NACK occurred */ if (reg_val) { /* SW_STATUS_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(3)); if (ddc_data->retry == 1) /* SOFT_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(1)); if (ddc_data->retry DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d\n", __func__, ddc_data->what, reg_val, ddc_data->retry); DEV_DBG("%s: daddr=0x%02x,off=0x%02x,len=%d\n", __func__, ddc_data->dev_addr, ddc_data->offset, ddc_data->data_len); goto again; } status = -EIO; if (log_retry_fail) { DEV_ERR("%s(%s): failed NACK=0x%08x\n", __func__, ddc_data->what, reg_val); DEV_ERR("%s: daddr=0x%02x,off=0x%02x,len=%d\n", __func__, ddc_data->dev_addr, ddc_data->offset, ddc_data->data_len); } goto error; } /* * 8. ALL data is now available and waiting in the DDC buffer. * Read HDMI_I2C_DATA with the following fields set * RW = 0x1 (read) * DATA = BCAPS (this is field where data is pulled from) * INDEX = 0x3 (where the data has been placed in buffer by hardware) * INDEX_WRITE = 0x1 (explicitly define offset) */ /* Write this data to DDC buffer */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, BIT(0) | (3 << 16) | BIT(31)); /* Discard first byte */ DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_DATA); for (ndx = 0; ndx < ddc_data->data_len; ++ndx) { reg_val = DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_DATA); ddc_data->data_buf[ndx] = (u8)((reg_val & 0x0000FF00) >> 8); } DEV_DBG("%s[%s] success\n", __func__, ddc_data->what); error: return status; } /* hdmi_ddc_read_retry */ void hdmi_ddc_config(struct hdmi_tx_ddc_ctrl *ddc_ctrl) { if (!ddc_ctrl || !ddc_ctrl->io) { DEV_ERR("%s: invalid input\n", __func__); return; } /* Configure Pre-Scale multiplier & Threshold */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_SPEED, (10 << 16) | (2 << 0)); /* * Setting 31:24 bits : Time units to wait before timeout * when clock is being stalled by external sink device */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_SETUP, 0xFF000000); /* Enable reference timer to 19 micro-seconds */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_REF, (1 << 16) | (19 << 0)); } /* hdmi_ddc_config */ int hdmi_ddc_isr(struct hdmi_tx_ddc_ctrl *ddc_ctrl) { u32 ddc_int_ctrl; if (!ddc_ctrl || !ddc_ctrl->io) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } ddc_int_ctrl = DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL); if ((ddc_int_ctrl & BIT(2)) && (ddc_int_ctrl & BIT(0))) { /* SW_DONE INT occured, clr it */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL, ddc_int_ctrl | BIT(1)); complete(&ddc_ctrl->ddc_sw_done); } DEV_DBG("%s: ddc_int_ctrl=%04x\n", __func__, ddc_int_ctrl); return 0; } /* hdmi_ddc_isr */ int hdmi_ddc_read(struct hdmi_tx_ddc_ctrl *ddc_ctrl, struct hdmi_tx_ddc_data *ddc_data) { int rc = 0; if (!ddc_ctrl || !ddc_data) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } rc = hdmi_ddc_read_retry(ddc_ctrl, ddc_data); if (!rc) return rc; if (ddc_data->no_align) { rc = hdmi_ddc_read_retry(ddc_ctrl, ddc_data); } else { ddc_data->request_len = 32 * ((ddc_data->data_len + 31) / 32); rc = hdmi_ddc_read_retry(ddc_ctrl, ddc_data); } return rc; } /* hdmi_ddc_read */ int hdmi_ddc_read_seg(struct hdmi_tx_ddc_ctrl *ddc_ctrl, struct hdmi_tx_ddc_data *ddc_data) { int status = 0; u32 reg_val, ndx, time_out_count; int log_retry_fail; int seg_addr = 0x60, seg_num = 0x01; if (!ddc_ctrl || !ddc_ctrl->io || !ddc_data) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } if (!ddc_data->data_buf) { status = -EINVAL; DEV_ERR("%s[%s]: invalid buf\n", __func__, ddc_data->what); goto error; } log_retry_fail = ddc_data->retry != 1; again: status = hdmi_ddc_clear_irq(ddc_ctrl, ddc_data->what); if (status) goto error; /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ ddc_data->dev_addr &= 0xFE; /* * 1. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #1 * DATA_RW = 0x0 (write) * DATA = linkAddress (primary link address and writing) * INDEX = 0x0 (initial offset into buffer) * INDEX_WRITE = 0x1 (setting initial offset) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, BIT(31) | (seg_addr << 8)); /* * 2. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #2 * DATA_RW = 0x0 (write) * DATA = offsetAddress * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, seg_num << 8); /* * 3. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #3 * DATA_RW = 0x0 (write) * DATA = linkAddress + 1 (primary link address 0x74 and reading) * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, ddc_data->dev_addr << 8); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, ddc_data->offset << 8); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, (ddc_data->dev_addr | BIT(0)) << 8); /* Data setup is complete, now setup the transaction characteristics */ /* * 4. Write to <API key> with the following fields set in * order to handle characteristics of portion #1 and portion #2 * RW0 = 0x0 (write) * START0 = 0x1 (insert START bit) * STOP0 = 0x0 (do NOT insert STOP bit) * CNT0 = 0x1 (single byte transaction excluding address) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS0, BIT(12) | BIT(16)); /* * 5. Write to <API key> with the following fields set in * order to handle characteristics of portion #3 * RW1 = 0x1 (read) * START1 = 0x1 (insert START bit) * STOP1 = 0x1 (insert STOP bit) * CNT1 = data_len (it's 128 (0x80) for a blk read) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS1, BIT(12) | BIT(16)); /* * 5. Write to <API key> with the following fields set in * order to handle characteristics of portion #3 * RW1 = 0x1 (read) * START1 = 0x1 (insert START bit) * STOP1 = 0x1 (insert STOP bit) * CNT1 = data_len (it's 128 (0x80) for a blk read) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS2, BIT(0) | BIT(12) | BIT(13) | (ddc_data->request_len << 16)); /* Trigger the I2C transfer */ /* * 6. Write to HDMI_I2C_CONTROL to kick off the hardware. * Note that NOTHING has been transmitted on the DDC lines up to this * point. * TRANSACTION_CNT = 0x2 (execute transaction0 followed by * transaction1) * GO = 0x1 (kicks off hardware) */ INIT_COMPLETION(ddc_ctrl->ddc_sw_done); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(0) | BIT(21)); time_out_count = <API key>( &ddc_ctrl->ddc_sw_done, HZ/2); reg_val = DSS_REG_R(ddc_ctrl->io, HDMI_DDC_INT_CTRL); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL, reg_val & (~BIT(2))); if (!time_out_count) { if (ddc_data->retry DEV_INFO("%s: failed timout, retry=%d\n", __func__, ddc_data->retry); goto again; } status = -ETIMEDOUT; DEV_ERR("%s: timedout(7), Int Ctrl=%08x\n", __func__, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_INT_CTRL)); DEV_ERR("%s: DDC SW Status=%08x, HW Status=%08x\n", __func__, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_SW_STATUS), DSS_REG_R(ddc_ctrl->io, HDMI_DDC_HW_STATUS)); goto error; } /* Read DDC status */ reg_val = DSS_REG_R(ddc_ctrl->io, HDMI_DDC_SW_STATUS); reg_val &= BIT(12) | BIT(13) | BIT(14) | BIT(15); /* Check if any NACK occurred */ if (reg_val) { /* SW_STATUS_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(3)); if (ddc_data->retry == 1) /* SOFT_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(1)); if (ddc_data->retry DEV_DBG("%s(%s): failed NACK=0x%08x, retry=%d\n", __func__, ddc_data->what, reg_val, ddc_data->retry); DEV_DBG("%s: daddr=0x%02x,off=0x%02x,len=%d\n", __func__, ddc_data->dev_addr, ddc_data->offset, ddc_data->data_len); goto again; } status = -EIO; if (log_retry_fail) { DEV_ERR("%s(%s): failed NACK=0x%08x\n", __func__, ddc_data->what, reg_val); DEV_ERR("%s: daddr=0x%02x,off=0x%02x,len=%d\n", __func__, ddc_data->dev_addr, ddc_data->offset, ddc_data->data_len); } goto error; } /* * 8. ALL data is now available and waiting in the DDC buffer. * Read HDMI_I2C_DATA with the following fields set * RW = 0x1 (read) * DATA = BCAPS (this is field where data is pulled from) * INDEX = 0x5 (where the data has been placed in buffer by hardware) * INDEX_WRITE = 0x1 (explicitly define offset) */ /* Write this data to DDC buffer */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, BIT(0) | (5 << 16) | BIT(31)); /* Discard first byte */ DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_DATA); for (ndx = 0; ndx < ddc_data->data_len; ++ndx) { reg_val = DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_DATA); ddc_data->data_buf[ndx] = (u8) ((reg_val & 0x0000FF00) >> 8); } DEV_DBG("%s[%s] success\n", __func__, ddc_data->what); error: return status; } /* hdmi_ddc_read_seg */ int hdmi_ddc_write(struct hdmi_tx_ddc_ctrl *ddc_ctrl, struct hdmi_tx_ddc_data *ddc_data) { u32 reg_val, ndx; int status = 0, retry = 10; u32 time_out_count; if (!ddc_ctrl || !ddc_ctrl->io || !ddc_data) { DEV_ERR("%s: invalid input\n", __func__); return -EINVAL; } if (!ddc_data->data_buf) { status = -EINVAL; DEV_ERR("%s[%s]: invalid buf\n", __func__, ddc_data->what); goto error; } again: status = hdmi_ddc_clear_irq(ddc_ctrl, ddc_data->what); if (status) goto error; /* Ensure Device Address has LSB set to 0 to indicate Slave addr read */ ddc_data->dev_addr &= 0xFE; /* * 1. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #1 * DATA_RW = 0x1 (write) * DATA = linkAddress (primary link address and writing) * INDEX = 0x0 (initial offset into buffer) * INDEX_WRITE = 0x1 (setting initial offset) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, BIT(31) | (ddc_data->dev_addr << 8)); /* * 2. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #2 * DATA_RW = 0x0 (write) * DATA = offsetAddress * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, ddc_data->offset << 8); /* * 3. Write to HDMI_I2C_DATA with the following fields set in order to * handle portion #3 * DATA_RW = 0x0 (write) * DATA = data_buf[ndx] * INDEX = 0x0 * INDEX_WRITE = 0x0 (auto-increment by hardware) */ for (ndx = 0; ndx < ddc_data->data_len; ++ndx) DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_DATA, ((u32)ddc_data->data_buf[ndx]) << 8); /* Data setup is complete, now setup the transaction characteristics */ /* * 4. Write to <API key> with the following fields set in * order to handle characteristics of portion #1 and portion #2 * RW0 = 0x0 (write) * START0 = 0x1 (insert START bit) * STOP0 = 0x0 (do NOT insert STOP bit) * CNT0 = 0x1 (single byte transaction excluding address) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS0, BIT(12) | BIT(16)); /* * 5. Write to <API key> with the following fields set in * order to handle characteristics of portion #3 * RW1 = 0x1 (read) * START1 = 0x1 (insert START bit) * STOP1 = 0x1 (insert STOP bit) * CNT1 = data_len (0xN (write N bytes of data)) * Byte count for second transition (excluding the first * Byte which is usually the address) */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_TRANS1, BIT(13) | ((ddc_data->data_len-1) << 16)); /* Trigger the I2C transfer */ /* * 6. Write to HDMI_I2C_CONTROL to kick off the hardware. * Note that NOTHING has been transmitted on the DDC lines up to this * point. * TRANSACTION_CNT = 0x1 (execute transaction0 followed by * transaction1) * GO = 0x1 (kicks off hardware) */ INIT_COMPLETION(ddc_ctrl->ddc_sw_done); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(0) | BIT(20)); time_out_count = <API key>( &ddc_ctrl->ddc_sw_done, HZ/2); reg_val = DSS_REG_R(ddc_ctrl->io, HDMI_DDC_INT_CTRL); DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_INT_CTRL, reg_val & (~BIT(2))); if (!time_out_count) { if (retry DEV_INFO("%s[%s]: failed timout, retry=%d\n", __func__, ddc_data->what, retry); goto again; } status = -ETIMEDOUT; DEV_ERR("%s[%s]: timedout, Int Ctrl=%08x\n", __func__, ddc_data->what, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_INT_CTRL)); DEV_ERR("%s: DDC SW Status=%08x, HW Status=%08x\n", __func__, DSS_REG_R(ddc_ctrl->io, HDMI_DDC_SW_STATUS), DSS_REG_R(ddc_ctrl->io, HDMI_DDC_HW_STATUS)); goto error; } /* Read DDC status */ reg_val = DSS_REG_R_ND(ddc_ctrl->io, HDMI_DDC_SW_STATUS); reg_val &= 0x00001000 | 0x00002000 | 0x00004000 | 0x00008000; /* Check if any NACK occurred */ if (reg_val) { if (retry > 1) /* SW_STATUS_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(3)); else /* SOFT_RESET */ DSS_REG_W_ND(ddc_ctrl->io, HDMI_DDC_CTRL, BIT(1)); if (retry DEV_DBG("%s[%s]: failed NACK=%08x, retry=%d\n", __func__, ddc_data->what, reg_val, retry); msleep(100); goto again; } status = -EIO; DEV_ERR("%s[%s]: failed NACK: %08x\n", __func__, ddc_data->what, reg_val); goto error; } DEV_DBG("%s[%s] success\n", __func__, ddc_data->what); error: return status; } /* hdmi_ddc_write */
#if !defined(CONFIG_M32R_CFC_NUM) #define M32R_MAX_PCC 2 #else #define M32R_MAX_PCC CONFIG_M32R_CFC_NUM #endif #define M32R_PCC0_BASE 0x00ef7000 #define M32R_PCC1_BASE 0x00ef7020 #define PCCR 0x00 #define PCADR 0x04 #define PCMOD 0x08 #define PCIRC 0x0c #define PCCSIGCR 0x10 #define PCATCR 0x14 #define PCCR_PCEN (1UL<<(31-31)) #define PCIRC_BWERR (1UL<<(31-7)) #define PCIRC_CDIN1 (1UL<<(31-14)) #define PCIRC_CDIN2 (1UL<<(31-15)) #define PCIRC_BEIEN (1UL<<(31-23)) #define PCIRC_CIIEN (1UL<<(31-30)) #define PCIRC_COIEN (1UL<<(31-31)) #define PCCSIGCR_SEN (1UL<<(31-3)) #define PCCSIGCR_VEN (1UL<<(31-7)) #define PCCSIGCR_CRST (1UL<<(31-15)) #define PCCSIGCR_COCR (1UL<<(31-31)) #define PCMOD_AS_ATTRIB (1UL<<(31-19)) #define PCMOD_AS_IO (1UL<<(31-18)) #define PCMOD_CBSZ (1UL<<(31-23)) #define PCMOD_DBEX (1UL<<(31-31)) #define M32R_PCC0_MAPBASE 0x14000000 #define M32R_PCC1_MAPBASE 0x16000000 #define M32R_PCC_MAPMAX 0x02000000 #define M32R_PCC_MAPSIZE 0x00001000 #define M32R_PCC_MAPMASK (~(M32R_PCC_MAPMAX-1)) #define CFC_IOPORT_BASE 0x1000 #if defined(CONFIG_PLAT_MAPPI3) #define CFC_ATTR_MAPBASE 0x14014000 #define CFC_IO_MAPBASE_BYTE 0xb4012000 #define CFC_IO_MAPBASE_WORD 0xb4002000 #elif !defined(CONFIG_PLAT_USRV) #define CFC_ATTR_MAPBASE 0x0c014000 #define CFC_IO_MAPBASE_BYTE 0xac012000 #define CFC_IO_MAPBASE_WORD 0xac002000 #else #define CFC_ATTR_MAPBASE 0x04014000 #define CFC_IO_MAPBASE_BYTE 0xa4012000 #define CFC_IO_MAPBASE_WORD 0xa4002000 #endif
package loci.formats.services; import java.io.<API key>; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.StringTokenizer; import java.util.Vector; import loci.common.Constants; import loci.common.Location; import loci.common.services.AbstractService; import loci.common.services.ServiceException; import loci.formats.FormatTools; import loci.formats.FormatException; import loci.formats.<API key>; import uk.ac.mrc.hgu.Wlz.WlzException; import uk.ac.mrc.hgu.Wlz.WlzGreyType; import uk.ac.mrc.hgu.Wlz.WlzObjectType; import uk.ac.mrc.hgu.Wlz.WlzFileStream; import uk.ac.mrc.hgu.Wlz.WlzFileInputStream; import uk.ac.mrc.hgu.Wlz.WlzFileOutputStream; import uk.ac.mrc.hgu.Wlz.WlzIBox2; import uk.ac.mrc.hgu.Wlz.WlzIBox3; import uk.ac.mrc.hgu.Wlz.WlzIVertex2; import uk.ac.mrc.hgu.Wlz.WlzIVertex3; import uk.ac.mrc.hgu.Wlz.WlzDVertex2; import uk.ac.mrc.hgu.Wlz.WlzDVertex3; import uk.ac.mrc.hgu.Wlz.WlzObject; public class WlzServiceImpl extends AbstractService implements WlzService { // -- Constants -- public static final String WLZ_ORG_LABEL = "WoolzOrigin"; public static final String NO_WLZ_MSG = "\n" + "Woolz is required to read and write Woolz objects.\n" + "Please obtain the necessary JAR and native library files from:\n" + "http: "The source code for these is also available from:\n" + "https://github.com/ma-tech/Woolz."; public static final int WLZ_SERVICE_UNKNOWN = 0; public static final int WLZ_SERVICE_READ = 1; public static final int WLZ_SERVICE_WRITE = 2; /* * Fields */ private int state = WLZ_SERVICE_UNKNOWN; private int pixelType = FormatTools.UINT8; private int objType = WlzObjectType.WLZ_NULL; /* objGType is the Woolz value type, but may be WLZ_GREY_ERROR to indicate * an object with no values, just a domain. */ private int objGType = WlzGreyType.WLZ_GREY_ERROR; private String wlzVersion = new String("unknown"); private WlzIBox3 bBox = null; private WlzDVertex3 voxSz = null; private WlzObject wlzObj = null; private WlzFileStream wlzFP = null; /* * Default constructor. */ public WlzServiceImpl() { <API key>(WlzObject.class); } @Override protected void <API key>(Class<? extends Object> klass) { String v[] = new String[1]; WlzObject.WlzGetVersion(v); } /* * Service methods */ @Override public String getNoWlzMsg() { return(new String(NO_WLZ_MSG)); } @Override public String getWlzOrgLabelName() { return(new String(WLZ_ORG_LABEL)); } @Override public void open(String file, String rw) throws FormatException, IOException { try { String v[] = new String[1]; WlzObject.WlzGetVersion(v); wlzVersion = new String(v[0]); } catch (<API key> e) { throw new FormatException(NO_WLZ_MSG, e); } if(rw.equals("r")) { openRead(file); } else if(rw.equals("w")) { openWrite(file); } else { throw new IOException("Failed to open file " + file); } } @Override public int getSizeX() { int sz; if(bBox == null) { sz = 0; } else { sz = bBox.xMax - bBox.xMin + 1; } return(sz); } @Override public int getSizeY() { int sz; if(bBox == null) { sz = 0; } else { sz = bBox.yMax - bBox.yMin + 1; } return(sz); } @Override public int getSizeZ() { int sz; if(bBox == null) { sz = 0; } else { sz = bBox.zMax - bBox.zMin + 1; } return(sz); } @Override public int getSizeC() { int sz; if(objGType == WlzGreyType.WLZ_GREY_RGBA) { sz = 4; } else { sz = 1; } return(sz); } @Override public int getSizeT() { return(1); } @Override public boolean isRGB() { boolean rgb; if(objGType == WlzGreyType.WLZ_GREY_RGBA) { rgb = true; } else { rgb = false; } return(rgb); } @Override public double getVoxSzX() { double sz; if(voxSz == null) { sz = 1.0; } else { sz = voxSz.vtX; } return(sz); } @Override public double getVoxSzY() { double sz; if(voxSz == null) { sz = 1.0; } else { sz = voxSz.vtY; } return(sz); } @Override public double getVoxSzZ() { double sz; if(voxSz == null) { sz = 1.0; } else { sz = voxSz.vtZ; } return(sz); } @Override public double getOrgX() { int og; if(bBox == null) { og = 0; } else { og = bBox.xMin; } return(og); } @Override public double getOrgY() { int og; if(bBox == null) { og = 0; } else { og = bBox.yMin; } return(og); } @Override public double getOrgZ() { int og; if(bBox == null) { og = 0; } else { og = bBox.zMin; } return(og); } @Override public int[] getSupPixelTypes() { return new int[] {FormatTools.UINT8, FormatTools.INT16, FormatTools.INT32, FormatTools.FLOAT, FormatTools.DOUBLE}; } @Override public int getPixelType() { int pixType; switch(objGType) { case WlzGreyType.WLZ_GREY_SHORT: pixelType = FormatTools.INT16; break; case WlzGreyType.WLZ_GREY_INT: pixelType = FormatTools.INT32; break; case WlzGreyType.WLZ_GREY_FLOAT: pixelType = FormatTools.FLOAT; break; case WlzGreyType.WLZ_GREY_DOUBLE: pixelType = FormatTools.DOUBLE; break; default: pixelType = FormatTools.UINT8; break; } return(pixelType); } @Override public void setupWrite(int orgX, int orgY, int orgZ, int pixSzX, int pixSzY, int pixSzZ, int pixSzC, int pixSzT, double voxSzX, double voxSzY, double voxSzZ, int gType) throws FormatException { bBox = new WlzIBox3(); bBox.xMin = orgX; bBox.yMin = orgY; bBox.zMin = orgZ; bBox.xMax = orgX + pixSzX - 1; bBox.yMax = orgY + pixSzY - 1; bBox.zMax = orgZ + pixSzZ - 1; voxSz = new WlzDVertex3(voxSzX, voxSzY, voxSzZ); if((bBox.xMax < bBox.xMin) || (bBox.yMax < bBox.yMin) || (bBox.zMax < bBox.zMin) || (pixSzC <= 0) || (pixSzT <= 0)) { throw new FormatException("Invalid image size (" + (bBox.xMax - bBox.xMin + 1) + ", " + (bBox.yMax - bBox.yMin + 1) + ", " + (bBox.zMax - bBox.zMin + 1) + ", " + pixSzC + ", " + pixSzT + ")"); } switch(gType) { case FormatTools.UINT8: objGType = WlzGreyType.WLZ_GREY_UBYTE; break; case FormatTools.INT16: objGType = WlzGreyType.WLZ_GREY_SHORT; break; case FormatTools.INT32: objGType = WlzGreyType.WLZ_GREY_INT; break; case FormatTools.FLOAT: objGType = WlzGreyType.WLZ_GREY_FLOAT; break; case FormatTools.DOUBLE: objGType = WlzGreyType.WLZ_GREY_DOUBLE; break; default: throw new FormatException("Invalid image value type"); } if(bBox.zMax == bBox.zMin) { objType = WlzObjectType.WLZ_2D_DOMAINOBJ; } else { objType = WlzObjectType.WLZ_3D_DOMAINOBJ; } try { wlzObj = WlzObject.WlzMakeEmpty(); } catch (WlzException e) { throw new FormatException("Failed to create Woolz object", e); } } @Override public void close() throws IOException { if(wlzObj != null) { if(state == WLZ_SERVICE_WRITE) { try { if(objType == WlzObjectType.WLZ_3D_DOMAINOBJ) { WlzObject.WlzSetVoxelSize(wlzObj, voxSz.vtX, voxSz.vtY, voxSz.vtZ); } WlzObject.WlzWriteObj(wlzFP, wlzObj); } catch(WlzException e) { throw new IOException("Failed to write to Woolz object (" + e + ")"); } } // Object is freed by garbage collection. wlzObj = null; } if(wlzFP != null) { wlzFP.close(); wlzFP = null; } } @Override public byte[] readBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { if((wlzObj == null) || (state != WLZ_SERVICE_READ)) { throw new FormatException("Uninitialised Woolz service"); } else { try { switch(objType) { case WlzObjectType.WLZ_2D_DOMAINOBJ: buf = readBytes2DDomObj(buf, x, y, w, h); break; case WlzObjectType.WLZ_3D_DOMAINOBJ: buf = readBytes3DDomObj(buf, x, y, no, w, h); break; default: throw new FormatException("Unsupported Woolz object type " + objType); } } catch (WlzException e) { throw new FormatException( "Failed to copy bytes from Woolz object (" + e + ")"); } } return(buf); } @Override public void saveBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { if(state == WLZ_SERVICE_WRITE) { WlzIVertex3 og = new WlzIVertex3(x + bBox.xMin, y + bBox.yMin, no + bBox.zMin); WlzIVertex2 sz = new WlzIVertex2(w, h); try { wlzObj = WlzObject.WlzBuildObj3B(wlzObj, og, sz, objGType, buf.length, buf); } catch (WlzException e) { throw new FormatException("Failed save bytes to Woolz object", e); } } } /* * Helper methods. */ private void openRead(String file) throws FormatException, IOException { state = WLZ_SERVICE_READ; try { wlzFP = new WlzFileInputStream(file); wlzObj = WlzObject.WlzReadObj(wlzFP); bBox = WlzObject.WlzBoundingBox3I(wlzObj); objType = WlzObject.WlzGetObjectType(wlzObj); if(objType == WlzObjectType.WLZ_3D_DOMAINOBJ) { voxSz = WlzObject.WlzGetVoxelSize(wlzObj); } else { voxSz = new WlzDVertex3(1.0, 1.0, 1.0); } } catch (WlzException e) { throw new IOException("Failed to read Woolz object (" + e + ")", e); } try { if (objType == WlzObjectType.WLZ_COMPOUND_ARR_1 || objType == WlzObjectType.WLZ_COMPOUND_ARR_2) { int count = objType == WlzObjectType.WLZ_COMPOUND_ARR_1 ? 1 : 2; WlzObject[][] dest = new WlzObject[1][count]; WlzObject.WlzExplode(new int[] {count}, dest, wlzObj); wlzObj = dest[0][0]; bBox = WlzObject.WlzBoundingBox3I(wlzObj); objType = WlzObject.WlzGetObjectType(wlzObj); if (objType == WlzObjectType.WLZ_3D_DOMAINOBJ) { voxSz = WlzObject.WlzGetVoxelSize(wlzObj); } } if(WlzObject.<API key>(wlzObj) != 0) { /* Here we use WLZ_GREY_ERROR to indicate that the object has no * values not an error. */ objGType = WlzGreyType.WLZ_GREY_ERROR; } else { // throw an exception here instead of segfaulting during readBytes* if (WlzObject.<API key>(wlzObj) > WlzObjectType.WLZ_GREY_TAB_TILED) { throw new FormatException("Value table data not supported"); } objGType = WlzObject.WlzGreyTypeFromObj(wlzObj); } } catch (WlzException e) { throw new FormatException( "Unable to determine Woolz object value type (" + e + ")", e); } switch(objGType) { case WlzGreyType.WLZ_GREY_UBYTE: break; case WlzGreyType.WLZ_GREY_SHORT: break; case WlzGreyType.WLZ_GREY_INT: break; case WlzGreyType.WLZ_GREY_FLOAT: break; case WlzGreyType.WLZ_GREY_DOUBLE: break; case WlzGreyType.WLZ_GREY_RGBA: break; case WlzGreyType.WLZ_GREY_ERROR: break; default: throw new FormatException( "Inappropriate Woolz object value type (type = " + objGType + ")"); } } private void openWrite(String file) throws FormatException, IOException { state = WLZ_SERVICE_WRITE; try { wlzFP = new WlzFileOutputStream(file); } catch (IOException e) { throw new IOException("Failed to open " + file + "for writing."); } } private byte[] readBytes2DDomObj(byte[] buf, int x, int y, int w, int h) throws WlzException { WlzIVertex2 og = new WlzIVertex2(x + bBox.xMin, y + bBox.yMin); WlzIVertex2 sz = new WlzIVertex2(w, h); WlzIVertex2 dstSz[] = new WlzIVertex2[1]; dstSz[0] = null; switch(objGType) { case WlzGreyType.WLZ_GREY_UBYTE: { byte dstDat[][][] = new byte[1][][]; WlzObject.WlzToUArray2D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { buf[idYW + idX] = dstDat[0][idY][idX]; } } } break; case WlzGreyType.WLZ_GREY_SHORT: { short m = 0xff; short dstDat[][][] = new short[1][][]; WlzObject.WlzToSArray2D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { short p = dstDat[0][idY][idX]; buf[2 * (idYW + idX)] = (byte )((p >>> 8) & m); buf[2 * (idYW + idX) + 1] = (byte )(p & m); } } } break; case WlzGreyType.WLZ_GREY_INT: { int m = 0xff; int dstDat[][][] = new int[1][][]; WlzObject.WlzToIArray2D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { int p = dstDat[0][idY][idX]; buf[idYW + (4 * idX)] = (byte )((p >> 24) & m); buf[idYW + (4 * idX) + 1] = (byte )((p >> 16) & m); buf[idYW + (4 * idX) + 2] = (byte )((p >> 8) & m); buf[idYW + (4 * idX) + 3] = (byte )(p & m); } } } break; case WlzGreyType.WLZ_GREY_RGBA: { int m = 0xff; int cOff = h * w; int dstDat[][][] = new int[1][][]; WlzObject.WlzToRArray2D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { int idYWX = idYW + idX; int p = dstDat[0][idY][idX]; buf[idYWX] = (byte )((p >> 0) & m); buf[idYWX + cOff] = (byte )((p >> 8) & m); buf[idYWX + (2 * cOff)] = (byte )((p >> 16) & m); buf[idYWX + (3 * cOff)] = (byte )((p >> 24) & m); } } } break; case WlzGreyType.WLZ_GREY_ERROR: /* Indicates no values. */ { int w8 = (w + 7) / 8; byte dstDat[][][] = new byte[1][][]; WlzObject.WlzToBArray2D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; int idYW8 = idY * w8; for(int idX = 0; idX < w; ++idX) { byte p = dstDat[0][idY][idX / 8]; byte b = (byte )(p & (0x01 << (idX % 8))); if(b == 0){ buf[idYW + idX] = (byte )0x00; } else { buf[idYW + idX] = (byte )0xff; } } } } break; default: throw new WlzException("Unsupported pixel type"); } return(buf); } private byte[] readBytes3DDomObj(byte[] buf, int x, int y, int z, int w, int h) throws WlzException { WlzIVertex3 og = new WlzIVertex3(x + bBox.xMin, y + bBox.yMin, z + bBox.zMin); WlzIVertex3 sz = new WlzIVertex3(w, h, 1); WlzIVertex3 dstSz[] = new WlzIVertex3[1]; dstSz[0] = null; switch(objGType) { case WlzGreyType.WLZ_GREY_UBYTE: { byte dstDat[][][][] = new byte[1][][][]; WlzObject.WlzToUArray3D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { buf[idYW + idX] = dstDat[0][0][idY][idX]; } } } break; case WlzGreyType.WLZ_GREY_SHORT: { short m = 0xff; short dstDat[][][][] = new short[1][][][]; WlzObject.WlzToSArray3D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { short p = dstDat[0][0][idY][idX]; buf[2 * (idYW + idX)] = (byte )((p >>> 8) & m); buf[2 * (idYW + idX) + 1] = (byte )(p & m); } } } break; case WlzGreyType.WLZ_GREY_INT: { int m = 0xff; int dstDat[][][][] = new int[1][][][]; WlzObject.WlzToIArray3D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { int p = dstDat[0][0][idY][idX]; buf[idYW + (4 * idX)] = (byte )((p >> 24) & m); buf[idYW + (4 * idX) + 1] = (byte )((p >> 16) & m); buf[idYW + (4 * idX) + 2] = (byte )((p >> 8) & m); buf[idYW + (4 * idX) + 3] = (byte )(p & m); } } } break; case WlzGreyType.WLZ_GREY_RGBA: { int m = 0xff; int cOff = h * w; int dstDat[][][][] = new int[1][][][]; WlzObject.WlzToRArray3D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; for(int idX = 0; idX < w; ++idX) { int idYWX = idYW + idX; int p = dstDat[0][0][idY][idX]; buf[idYWX] = (byte )((p >> 0) & m); buf[idYWX + cOff] = (byte )((p >> 8) & m); buf[idYWX + (2 * cOff)] = (byte )((p >> 16) & m); buf[idYWX + (3 * cOff)] = (byte )((p >> 24) & m); } } } break; case WlzGreyType.WLZ_GREY_ERROR: /* Indicates no values. */ { int w8 = (w + 7) / 8; byte dstDat[][][][] = new byte[1][][][]; WlzObject.WlzToBArray3D(dstSz, dstDat, wlzObj, og, sz, 0); for(int idY = 0; idY < h; ++idY) { int idYW = idY * w; int idYW8 = idY * w8; for(int idX = 0; idX < w; ++idX) { byte p = dstDat[0][0][idY][idX / 8]; byte b = (byte )(p & (0x01 << (idX % 8))); if(b == 0){ buf[idYW + idX] = (byte )0x00; } else { buf[idYW + idX] = (byte )0xff; } } } } break; default: throw new WlzException("Unsupported pixel type"); } return(buf); } }
#ifndef _VPBE_TYPES_H #define _VPBE_TYPES_H enum vpbe_version { VPBE_VERSION_1 = 1, VPBE_VERSION_2, VPBE_VERSION_3, }; enum <API key> { VPBE_ENC_STD = 0x1, VPBE_ENC_DV_PRESET = 0x2, <API key> = 0x4, <API key> = 0x8, }; union vpbe_timings { v4l2_std_id std_id; unsigned int dv_preset; }; struct vpbe_enc_mode_info { unsigned char *name; enum <API key> timings_type; union vpbe_timings timings; unsigned int interlaced; unsigned int xres; unsigned int yres; struct v4l2_fract aspect; struct v4l2_fract fps; unsigned int left_margin; unsigned int right_margin; unsigned int upper_margin; unsigned int lower_margin; unsigned int hsync_len; unsigned int vsync_len; unsigned int flags; }; #endif
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ #include <config.h> #include "eel-background-box.h" #include "eel-background.h" G_DEFINE_TYPE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX) static gboolean <API key> (GtkWidget *widget, #if GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr) #else GdkEventExpose *event) #endif { #if GTK_CHECK_VERSION (3, 0, 0) eel_background_draw (widget, cr); <API key> (GTK_CONTAINER (widget), gtk_bin_get_child (GTK_BIN (widget)), cr); #else eel_background_draw (widget, event); <API key> (GTK_CONTAINER (widget), gtk_bin_get_child (GTK_BIN (widget)), event); #endif return TRUE; } static void <API key> (EelBackgroundBox *box) { } static void <API key> (<API key> *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); #if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = <API key>; #else widget_class->expose_event = <API key>; #endif } GtkWidget* <API key> (void) { EelBackgroundBox *background_box; background_box = EEL_BACKGROUND_BOX (gtk_widget_new (<API key> (), NULL)); return GTK_WIDGET (background_box); }
/* * utime.h */ #ifndef _UTIME_H #define _UTIME_H #include <klibc/extern.h> #include <sys/types.h> #include <linux/utime.h> __extern int utime(const char *, const struct utimbuf *); #endif /* _UTIME_H */
#include "emu.h" #include "cpu/z80/z80.h" #include "machine/terminal.h" #define TERMINAL_TAG "terminal" class ccs300_state : public driver_device { public: ccs300_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_terminal(*this, TERMINAL_TAG) { } DECLARE_DRIVER_INIT(ccs300); <API key>(ccs300); <API key>(port10_r); <API key>(port11_r); <API key>(port10_w); <API key>(port40_w); <API key>(kbd_put); private: UINT8 m_term_data; required_device<cpu_device> m_maincpu; required_device<<API key>> m_terminal; }; static ADDRESS_MAP_START(ccs300_mem, AS_PROGRAM, 8, ccs300_state) <API key> AM_RANGE(0x0000, 0x07ff) AM_READ_BANK("bankr0") AM_WRITE_BANK("bankw0") AM_RANGE(0x0800, 0xffff) AM_RAM ADDRESS_MAP_END static ADDRESS_MAP_START( ccs300_io, AS_IO, 8, ccs300_state) <API key> <API key>(0xff) AM_RANGE(0x10, 0x10) AM_READWRITE(port10_r,port10_w) AM_RANGE(0x11, 0x11) AM_READ(port11_r) AM_RANGE(0x40, 0x40) AM_WRITE(port40_w) ADDRESS_MAP_END /* Input ports */ static INPUT_PORTS_START( ccs300 ) INPUT_PORTS_END /* basic machine hardware */ /* video hardware */ /* ROM definition */ /* Driver */ /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */
<?php // No direct access defined('_JEXEC') or die; /** * T3Hook: load custom code * Hook function is defined in theme with format: [theme folder]_[theme name]_[hook_name] * Eg: <API key>: defined in theme blue in core folder * Eg: custom_body_class: defined in default theme of template * * @package JAT3.Core */ class T3Hook extends JObject { /** * Call hook function * * @param string $hookname Hook function name * @param array $args List of arguments * * @return mixed Returns the function result, or FALSE on error. */ public static function _($hookname, $args = array()) { //load custom hook T3Hook::_load(); //find hook function $themes = T3Common::get_active_themes(); foreach ($themes as $theme) { $func = $theme[0] . "_" . $theme[1] . "_" . $hookname; if (function_exists($func)) return <API key>($func, $args); } if (function_exists($hookname)) return <API key>($hookname, $args); if (function_exists("T3Hook::$hookname")) return <API key>("T3Hook::$hookname", $args); return false; } /** * Load hook file * * @return void */ public static function _load() { if (defined('_T3_HOOK_CUSTOM')) return; define('_T3_HOOK_CUSTOM', 1); //include hook. Get all path to hook.php in themes $paths = T3Path::getPath('hook.php', true); if (is_array($paths)) { foreach ($paths as $path) include $path; } } }
#include <linux/param.h> #include <linux/time.h> #include <linux/mm.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/in.h> #include <linux/pagemap.h> #include <linux/proc_fs.h> #include <linux/kdev_t.h> #include <linux/sunrpc/clnt.h> #include <linux/nfs.h> #include <linux/nfs3.h> #include <linux/nfs_fs.h> #include <linux/nfsacl.h> #include "internal.h" #define NFSDBG_FACILITY NFSDBG_XDR #define errno_NFSERR_IO EIO #define NFS3_fhandle_sz (1+16) #define NFS3_fh_sz (NFS3_fhandle_sz) #define NFS3_sattr_sz (15) #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2)) #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2)) #define NFS3_fattr_sz (21) #define NFS3_cookieverf_sz (NFS3_COOKIEVERFSIZE>>2) #define NFS3_wcc_attr_sz (6) #define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz) #define <API key> (1+NFS3_fattr_sz) #define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+<API key>) #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz) #define NFS3_getattrargs_sz (NFS3_fh_sz) #define NFS3_setattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3) #define NFS3_lookupargs_sz (NFS3_fh_sz+NFS3_filename_sz) #define NFS3_accessargs_sz (NFS3_fh_sz+1) #define <API key> (NFS3_fh_sz) #define NFS3_readargs_sz (NFS3_fh_sz+3) #define NFS3_writeargs_sz (NFS3_fh_sz+5) #define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz) #define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz) #define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz) #define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz) #define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz) #define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz) #define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz) #define NFS3_readdirargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+3) #define <API key> (NFS3_fh_sz+NFS3_cookieverf_sz+4) #define NFS3_commitargs_sz (NFS3_fh_sz+3) #define NFS3_getattrres_sz (1+NFS3_fattr_sz) #define NFS3_setattrres_sz (1+NFS3_wcc_data_sz) #define NFS3_removeres_sz (NFS3_setattrres_sz) #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * <API key>)) #define NFS3_accessres_sz (1+<API key>+1) #define NFS3_readlinkres_sz (1+<API key>+1) #define NFS3_readres_sz (1+<API key>+3) #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4) #define NFS3_createres_sz (1+NFS3_fh_sz+<API key>+NFS3_wcc_data_sz) #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz)) #define NFS3_linkres_sz (1+<API key>+NFS3_wcc_data_sz) #define NFS3_readdirres_sz (1+<API key>+2) #define NFS3_fsstatres_sz (1+<API key>+13) #define NFS3_fsinfores_sz (1+<API key>+12) #define NFS3_pathconfres_sz (1+<API key>+6) #define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2) #define ACL3_getaclargs_sz (NFS3_fh_sz+1) #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \ XDR_QUADLEN(<API key>)) #define ACL3_getaclres_sz (1+<API key>+1+ \ XDR_QUADLEN(<API key>)) #define ACL3_setaclres_sz (1+<API key>) static const umode_t nfs_type2fmt[] = { [NF3BAD] = 0, [NF3REG] = S_IFREG, [NF3DIR] = S_IFDIR, [NF3BLK] = S_IFBLK, [NF3CHR] = S_IFCHR, [NF3LNK] = S_IFLNK, [NF3SOCK] = S_IFSOCK, [NF3FIFO] = S_IFIFO, }; static void <API key>(struct rpc_rqst *req, struct page **pages, unsigned int base, unsigned int len, unsigned int bufsize) { struct rpc_auth *auth = req->rq_cred->cr_auth; unsigned int replen; replen = RPC_REPHDRSIZE + auth->au_rslack + bufsize; xdr_inline_pages(&req->rq_rcv_buf, replen << 2, pages, base, len); } static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) { dprintk("NFS: %s prematurely hit the end of our receive buffer. " "Remaining buffer length is %tu words.\n", func, xdr->end - xdr->p); } static void encode_uint32(struct xdr_stream *xdr, u32 value) { __be32 *p = xdr_reserve_space(xdr, 4); *p = cpu_to_be32(value); } static int decode_uint32(struct xdr_stream *xdr, u32 *value) { __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; *value = be32_to_cpup(p); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int decode_uint64(struct xdr_stream *xdr, u64 *value) { __be32 *p; p = xdr_inline_decode(xdr, 8); if (unlikely(p == NULL)) goto out_overflow; xdr_decode_hyper(p, value); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static __be32 *xdr_decode_fileid3(__be32 *p, u64 *fileid) { return xdr_decode_hyper(p, fileid); } static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid) { return decode_uint64(xdr, fileid); } static void encode_filename3(struct xdr_stream *xdr, const char *name, u32 length) { __be32 *p; BUG_ON(length > NFS3_MAXNAMLEN); p = xdr_reserve_space(xdr, 4 + length); xdr_encode_opaque(p, name, length); } static int <API key>(struct xdr_stream *xdr, const char **name, u32 *length) { __be32 *p; u32 count; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; count = be32_to_cpup(p); if (count > NFS3_MAXNAMLEN) goto out_nametoolong; p = xdr_inline_decode(xdr, count); if (unlikely(p == NULL)) goto out_overflow; *name = (const char *)p; *length = count; return 0; out_nametoolong: dprintk("NFS: returned filename too long: %u\n", count); return -ENAMETOOLONG; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static void encode_nfspath3(struct xdr_stream *xdr, struct page **pages, const u32 length) { BUG_ON(length > NFS3_MAXPATHLEN); encode_uint32(xdr, length); xdr_write_pages(xdr, pages, 0, length); } static int decode_nfspath3(struct xdr_stream *xdr) { u32 recvd, count; size_t hdrlen; __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; count = be32_to_cpup(p); if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN)) goto out_nametoolong; hdrlen = (u8 *)xdr->p - (u8 *)xdr->iov->iov_base; recvd = xdr->buf->len - hdrlen; if (unlikely(count > recvd)) goto out_cheating; xdr_read_pages(xdr, count); <API key>(xdr->buf, count); return 0; out_nametoolong: dprintk("NFS: returned pathname too long: %u\n", count); return -ENAMETOOLONG; out_cheating: dprintk("NFS: server cheating in pathname result: " "count %u > recvd %u\n", count, recvd); return -EIO; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static __be32 *xdr_encode_cookie3(__be32 *p, u64 cookie) { return xdr_encode_hyper(p, cookie); } static int decode_cookie3(struct xdr_stream *xdr, u64 *cookie) { return decode_uint64(xdr, cookie); } static __be32 *<API key>(__be32 *p, const __be32 *verifier) { memcpy(p, verifier, NFS3_COOKIEVERFSIZE); return p + XDR_QUADLEN(NFS3_COOKIEVERFSIZE); } static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier) { __be32 *p; p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE); if (unlikely(p == NULL)) goto out_overflow; memcpy(verifier, p, NFS3_COOKIEVERFSIZE); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier) { __be32 *p; p = xdr_reserve_space(xdr, NFS3_CREATEVERFSIZE); memcpy(p, verifier, NFS3_CREATEVERFSIZE); } static int decode_writeverf3(struct xdr_stream *xdr, __be32 *verifier) { __be32 *p; p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE); if (unlikely(p == NULL)) goto out_overflow; memcpy(verifier, p, NFS3_WRITEVERFSIZE); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static __be32 *xdr_decode_size3(__be32 *p, u64 *size) { return xdr_decode_hyper(p, size); } #define NFS3_OK NFS_OK static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status) { __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; *status = be32_to_cpup(p); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static void encode_ftype3(struct xdr_stream *xdr, const u32 type) { BUG_ON(type > NF3FIFO); encode_uint32(xdr, type); } static __be32 *xdr_decode_ftype3(__be32 *p, umode_t *mode) { u32 type; type = be32_to_cpup(p++); if (type > NF3FIFO) type = NF3NON; *mode = nfs_type2fmt[type]; return p; } static void encode_specdata3(struct xdr_stream *xdr, const dev_t rdev) { __be32 *p; p = xdr_reserve_space(xdr, 8); *p++ = cpu_to_be32(MAJOR(rdev)); *p = cpu_to_be32(MINOR(rdev)); } static __be32 *<API key>(__be32 *p, dev_t *rdev) { unsigned int major, minor; major = be32_to_cpup(p++); minor = be32_to_cpup(p++); *rdev = MKDEV(major, minor); if (MAJOR(*rdev) != major || MINOR(*rdev) != minor) *rdev = 0; return p; } static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh) { __be32 *p; BUG_ON(fh->size > NFS3_FHSIZE); p = xdr_reserve_space(xdr, 4 + fh->size); xdr_encode_opaque(p, fh->data, fh->size); } static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) { u32 length; __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; length = be32_to_cpup(p++); if (unlikely(length > NFS3_FHSIZE)) goto out_toobig; p = xdr_inline_decode(xdr, length); if (unlikely(p == NULL)) goto out_overflow; fh->size = length; memcpy(fh->data, p, length); return 0; out_toobig: dprintk("NFS: file handle size (%u) too big\n", length); return -E2BIG; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static void zero_nfs_fh3(struct nfs_fh *fh) { memset(fh, 0, sizeof(*fh)); } static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec *timep) { *p++ = cpu_to_be32(timep->tv_sec); *p++ = cpu_to_be32(timep->tv_nsec); return p; } static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec *timep) { timep->tv_sec = be32_to_cpup(p++); timep->tv_nsec = be32_to_cpup(p++); return p; } static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr) { u32 nbytes; __be32 *p; nbytes = 6 * 4; if (attr->ia_valid & ATTR_MODE) nbytes += 4; if (attr->ia_valid & ATTR_UID) nbytes += 4; if (attr->ia_valid & ATTR_GID) nbytes += 4; if (attr->ia_valid & ATTR_SIZE) nbytes += 8; if (attr->ia_valid & ATTR_ATIME_SET) nbytes += 8; if (attr->ia_valid & ATTR_MTIME_SET) nbytes += 8; p = xdr_reserve_space(xdr, nbytes); if (attr->ia_valid & ATTR_MODE) { *p++ = xdr_one; *p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO); } else *p++ = xdr_zero; if (attr->ia_valid & ATTR_UID) { *p++ = xdr_one; *p++ = cpu_to_be32(attr->ia_uid); } else *p++ = xdr_zero; if (attr->ia_valid & ATTR_GID) { *p++ = xdr_one; *p++ = cpu_to_be32(attr->ia_gid); } else *p++ = xdr_zero; if (attr->ia_valid & ATTR_SIZE) { *p++ = xdr_one; p = xdr_encode_hyper(p, (u64)attr->ia_size); } else *p++ = xdr_zero; if (attr->ia_valid & ATTR_ATIME_SET) { *p++ = xdr_two; p = xdr_encode_nfstime3(p, &attr->ia_atime); } else if (attr->ia_valid & ATTR_ATIME) { *p++ = xdr_one; } else *p++ = xdr_zero; if (attr->ia_valid & ATTR_MTIME_SET) { *p++ = xdr_two; xdr_encode_nfstime3(p, &attr->ia_mtime); } else if (attr->ia_valid & ATTR_MTIME) { *p = xdr_one; } else *p = xdr_zero; } static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr) { umode_t fmode; __be32 *p; p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2); if (unlikely(p == NULL)) goto out_overflow; p = xdr_decode_ftype3(p, &fmode); fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode; fattr->nlink = be32_to_cpup(p++); fattr->uid = be32_to_cpup(p++); fattr->gid = be32_to_cpup(p++); p = xdr_decode_size3(p, &fattr->size); p = xdr_decode_size3(p, &fattr->du.nfs3.used); p = <API key>(p, &fattr->rdev); p = xdr_decode_hyper(p, &fattr->fsid.major); fattr->fsid.minor = 0; p = xdr_decode_fileid3(p, &fattr->fileid); p = xdr_decode_nfstime3(p, &fattr->atime); p = xdr_decode_nfstime3(p, &fattr->mtime); xdr_decode_nfstime3(p, &fattr->ctime); fattr->valid |= NFS_ATTR_FATTR_V3; return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) { __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p != xdr_zero) return decode_fattr3(xdr, fattr); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) { __be32 *p; p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2); if (unlikely(p == NULL)) goto out_overflow; fattr->valid |= <API key> | <API key> | <API key>; p = xdr_decode_size3(p, &fattr->pre_size); p = xdr_decode_nfstime3(p, &fattr->pre_mtime); xdr_decode_nfstime3(p, &fattr->pre_ctime); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr) { __be32 *p; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p != xdr_zero) return decode_wcc_attr(xdr, fattr); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr) { int error; error = decode_pre_op_attr(xdr, fattr); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, fattr); out: return error; } static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh) { __be32 *p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p != xdr_zero) return decode_nfs_fh3(xdr, fh); zero_nfs_fh3(fh); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static void encode_diropargs3(struct xdr_stream *xdr, const struct nfs_fh *fh, const char *name, u32 length) { encode_nfs_fh3(xdr, fh); encode_filename3(xdr, name, length); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_fh *fh) { encode_nfs_fh3(xdr, fh); } static void encode_sattrguard3(struct xdr_stream *xdr, const struct nfs3_sattrargs *args) { __be32 *p; if (args->guard) { p = xdr_reserve_space(xdr, 4 + 8); *p++ = xdr_one; xdr_encode_nfstime3(p, &args->guardtime); } else { p = xdr_reserve_space(xdr, 4); *p = xdr_zero; } } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_sattrargs *args) { encode_nfs_fh3(xdr, args->fh); encode_sattr3(xdr, args->sattr); encode_sattrguard3(xdr, args); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_diropargs *args) { encode_diropargs3(xdr, args->fh, args->name, args->len); } static void encode_access3args(struct xdr_stream *xdr, const struct nfs3_accessargs *args) { encode_nfs_fh3(xdr, args->fh); encode_uint32(xdr, args->access); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_accessargs *args) { encode_access3args(xdr, args); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_readlinkargs *args) { encode_nfs_fh3(xdr, args->fh); <API key>(req, args->pages, args->pgbase, args->pglen, NFS3_readlinkres_sz); } static void encode_read3args(struct xdr_stream *xdr, const struct nfs_readargs *args) { __be32 *p; encode_nfs_fh3(xdr, args->fh); p = xdr_reserve_space(xdr, 8 + 4); p = xdr_encode_hyper(p, args->offset); *p = cpu_to_be32(args->count); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_readargs *args) { encode_read3args(xdr, args); <API key>(req, args->pages, args->pgbase, args->count, NFS3_readres_sz); req->rq_rcv_buf.flags |= XDRBUF_READ; } static void encode_write3args(struct xdr_stream *xdr, const struct nfs_writeargs *args) { __be32 *p; encode_nfs_fh3(xdr, args->fh); p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4); p = xdr_encode_hyper(p, args->offset); *p++ = cpu_to_be32(args->count); *p++ = cpu_to_be32(args->stable); *p = cpu_to_be32(args->count); xdr_write_pages(xdr, args->pages, args->pgbase, args->count); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_writeargs *args) { encode_write3args(xdr, args); xdr->buf->flags |= XDRBUF_WRITE; } static void encode_createhow3(struct xdr_stream *xdr, const struct nfs3_createargs *args) { encode_uint32(xdr, args->createmode); switch (args->createmode) { case <API key>: case NFS3_CREATE_GUARDED: encode_sattr3(xdr, args->sattr); break; case <API key>: encode_createverf3(xdr, args->verifier); break; default: BUG(); } } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_createargs *args) { encode_diropargs3(xdr, args->fh, args->name, args->len); encode_createhow3(xdr, args); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_mkdirargs *args) { encode_diropargs3(xdr, args->fh, args->name, args->len); encode_sattr3(xdr, args->sattr); } static void encode_symlinkdata3(struct xdr_stream *xdr, const struct nfs3_symlinkargs *args) { encode_sattr3(xdr, args->sattr); encode_nfspath3(xdr, args->pages, args->pathlen); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_symlinkargs *args) { encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen); encode_symlinkdata3(xdr, args); } static void encode_devicedata3(struct xdr_stream *xdr, const struct nfs3_mknodargs *args) { encode_sattr3(xdr, args->sattr); encode_specdata3(xdr, args->rdev); } static void encode_mknoddata3(struct xdr_stream *xdr, const struct nfs3_mknodargs *args) { encode_ftype3(xdr, args->type); switch (args->type) { case NF3CHR: case NF3BLK: encode_devicedata3(xdr, args); break; case NF3SOCK: case NF3FIFO: encode_sattr3(xdr, args->sattr); break; case NF3REG: case NF3DIR: break; default: BUG(); } } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_mknodargs *args) { encode_diropargs3(xdr, args->fh, args->name, args->len); encode_mknoddata3(xdr, args); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_removeargs *args) { encode_diropargs3(xdr, args->fh, args->name.name, args->name.len); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_renameargs *args) { const struct qstr *old = args->old_name; const struct qstr *new = args->new_name; encode_diropargs3(xdr, args->old_dir, old->name, old->len); encode_diropargs3(xdr, args->new_dir, new->name, new->len); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_linkargs *args) { encode_nfs_fh3(xdr, args->fromfh); encode_diropargs3(xdr, args->tofh, args->toname, args->tolen); } static void encode_readdir3args(struct xdr_stream *xdr, const struct nfs3_readdirargs *args) { __be32 *p; encode_nfs_fh3(xdr, args->fh); p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4); p = xdr_encode_cookie3(p, args->cookie); p = <API key>(p, args->verf); *p = cpu_to_be32(args->count); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_readdirargs *args) { encode_readdir3args(xdr, args); <API key>(req, args->pages, 0, args->count, NFS3_readdirres_sz); } static void <API key>(struct xdr_stream *xdr, const struct nfs3_readdirargs *args) { __be32 *p; encode_nfs_fh3(xdr, args->fh); p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4 + 4); p = xdr_encode_cookie3(p, args->cookie); p = <API key>(p, args->verf); *p++ = cpu_to_be32(args->count >> 3); *p = cpu_to_be32(args->count); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_readdirargs *args) { <API key>(xdr, args); <API key>(req, args->pages, 0, args->count, NFS3_readdirres_sz); } static void encode_commit3args(struct xdr_stream *xdr, const struct nfs_writeargs *args) { __be32 *p; encode_nfs_fh3(xdr, args->fh); p = xdr_reserve_space(xdr, 8 + 4); p = xdr_encode_hyper(p, args->offset); *p = cpu_to_be32(args->count); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs_writeargs *args) { encode_commit3args(xdr, args); } #ifdef CONFIG_NFS_V3_ACL static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_getaclargs *args) { encode_nfs_fh3(xdr, args->fh); encode_uint32(xdr, args->mask); if (args->mask & (NFS_ACL | NFS_DFACL)) <API key>(req, args->pages, 0, NFSACL_MAXPAGES << PAGE_SHIFT, ACL3_getaclres_sz); } static void <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, const struct nfs3_setaclargs *args) { unsigned int base; int error; encode_nfs_fh3(xdr, NFS_FH(args->inode)); encode_uint32(xdr, args->mask); base = req->rq_slen; if (args->npages != 0) xdr_write_pages(xdr, args->pages, 0, args->len); else xdr_reserve_space(xdr, <API key>); error = nfsacl_encode(xdr->buf, base, args->inode, (args->mask & NFS_ACL) ? args->acl_access : NULL, 1, 0); BUG_ON(error < 0); error = nfsacl_encode(xdr->buf, base + error, args->inode, (args->mask & NFS_DFACL) ? args->acl_default : NULL, 1, NFS_ACL_DEFAULT); BUG_ON(error < 0); } #endif static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fattr *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_fattr3(xdr, result); out: return error; out_default: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fattr *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; out: return error; out_status: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_diropres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_nfs_fh3(xdr, result->fh); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->dir_attr); out: return error; out_default: error = decode_post_op_attr(xdr, result->dir_attr); if (unlikely(error)) goto out; return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_accessres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_uint32(xdr, &result->access); out: return error; out_default: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fattr *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_nfspath3(xdr); out: return error; out_default: return nfs_stat_to_errno(status); } static int decode_read3resok(struct xdr_stream *xdr, struct nfs_readres *result) { u32 eof, count, ocount, recvd; size_t hdrlen; __be32 *p; p = xdr_inline_decode(xdr, 4 + 4 + 4); if (unlikely(p == NULL)) goto out_overflow; count = be32_to_cpup(p++); eof = be32_to_cpup(p++); ocount = be32_to_cpup(p++); if (unlikely(ocount != count)) goto out_mismatch; hdrlen = (u8 *)xdr->p - (u8 *)xdr->iov->iov_base; recvd = xdr->buf->len - hdrlen; if (unlikely(count > recvd)) goto out_cheating; out: xdr_read_pages(xdr, count); result->eof = eof; result->count = count; return count; out_mismatch: dprintk("NFS: READ count doesn't match length of opaque: " "count %u != ocount %u\n", count, ocount); return -EIO; out_cheating: dprintk("NFS: server cheating in read result: " "count %u > recvd %u\n", count, recvd); count = recvd; eof = 0; goto out; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_readres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = decode_read3resok(xdr, result); out: return error; out_status: return nfs_stat_to_errno(status); } static int decode_write3resok(struct xdr_stream *xdr, struct nfs_writeres *result) { __be32 *p; p = xdr_inline_decode(xdr, 4 + 4 + NFS3_WRITEVERFSIZE); if (unlikely(p == NULL)) goto out_overflow; result->count = be32_to_cpup(p++); result->verf->committed = be32_to_cpup(p++); if (unlikely(result->verf->committed > NFS_FILE_SYNC)) goto out_badvalue; memcpy(result->verf->verifier, p, NFS3_WRITEVERFSIZE); return result->count; out_badvalue: dprintk("NFS: bad stable_how value: %u\n", result->verf->committed); return -EIO; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_writeres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = decode_write3resok(xdr, result); out: return error; out_status: return nfs_stat_to_errno(status); } static int decode_create3resok(struct xdr_stream *xdr, struct nfs3_diropres *result) { int error; error = decode_post_op_fh3(xdr, result->fh); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (result->fh->size == 0) result->fattr->valid = 0; error = decode_wcc_data(xdr, result->dir_attr); out: return error; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_diropres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_create3resok(xdr, result); out: return error; out_default: error = decode_wcc_data(xdr, result->dir_attr); if (unlikely(error)) goto out; return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_removeres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->dir_attr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; out: return error; out_status: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_renameres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->old_fattr); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->new_fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; out: return error; out_status: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_linkres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->dir_attr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; out: return error; out_status: return nfs_stat_to_errno(status); } int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, int plus) { struct nfs_entry old = *entry; __be32 *p; int error; p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p == xdr_zero) { p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p == xdr_zero) return -EAGAIN; entry->eof = 1; return -EBADCOOKIE; } error = decode_fileid3(xdr, &entry->ino); if (unlikely(error)) return error; error = <API key>(xdr, &entry->name, &entry->len); if (unlikely(error)) return error; entry->prev_cookie = entry->cookie; error = decode_cookie3(xdr, &entry->cookie); if (unlikely(error)) return error; entry->d_type = DT_UNKNOWN; if (plus) { entry->fattr->valid = 0; error = decode_post_op_attr(xdr, entry->fattr); if (unlikely(error)) return error; if (entry->fattr->valid & NFS_ATTR_FATTR_V3) entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); p = xdr_inline_decode(xdr, 4); if (unlikely(p == NULL)) goto out_overflow; if (*p != xdr_zero) { error = decode_nfs_fh3(xdr, entry->fh); if (unlikely(error)) { if (error == -E2BIG) goto out_truncated; return error; } } else zero_nfs_fh3(entry->fh); } return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EAGAIN; out_truncated: dprintk("NFS: directory entry contains invalid file handle\n"); *entry = old; return -EAGAIN; } static int decode_dirlist3(struct xdr_stream *xdr) { u32 recvd, pglen; size_t hdrlen; pglen = xdr->buf->page_len; hdrlen = (u8 *)xdr->p - (u8 *)xdr->iov->iov_base; recvd = xdr->buf->len - hdrlen; if (unlikely(pglen > recvd)) goto out_cheating; out: xdr_read_pages(xdr, pglen); return pglen; out_cheating: dprintk("NFS: server cheating in readdir result: " "pglen %u > recvd %u\n", pglen, recvd); pglen = recvd; goto out; } static int <API key>(struct xdr_stream *xdr, struct nfs3_readdirres *result) { int error; error = decode_post_op_attr(xdr, result->dir_attr); if (unlikely(error)) goto out; error = decode_cookieverf3(xdr, result->verf); if (unlikely(error)) goto out; error = decode_dirlist3(xdr); out: return error; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_readdirres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = <API key>(xdr, result); out: return error; out_default: error = decode_post_op_attr(xdr, result->dir_attr); if (unlikely(error)) goto out; return nfs_stat_to_errno(status); } static int decode_fsstat3resok(struct xdr_stream *xdr, struct nfs_fsstat *result) { __be32 *p; p = xdr_inline_decode(xdr, 8 * 6 + 4); if (unlikely(p == NULL)) goto out_overflow; p = xdr_decode_size3(p, &result->tbytes); p = xdr_decode_size3(p, &result->fbytes); p = xdr_decode_size3(p, &result->abytes); p = xdr_decode_size3(p, &result->tfiles); p = xdr_decode_size3(p, &result->ffiles); xdr_decode_size3(p, &result->afiles); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fsstat *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = decode_fsstat3resok(xdr, result); out: return error; out_status: return nfs_stat_to_errno(status); } static int decode_fsinfo3resok(struct xdr_stream *xdr, struct nfs_fsinfo *result) { __be32 *p; p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4); if (unlikely(p == NULL)) goto out_overflow; result->rtmax = be32_to_cpup(p++); result->rtpref = be32_to_cpup(p++); result->rtmult = be32_to_cpup(p++); result->wtmax = be32_to_cpup(p++); result->wtpref = be32_to_cpup(p++); result->wtmult = be32_to_cpup(p++); result->dtpref = be32_to_cpup(p++); p = xdr_decode_size3(p, &result->maxfilesize); xdr_decode_nfstime3(p, &result->time_delta); result->lease_time = 0; return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fsinfo *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = decode_fsinfo3resok(xdr, result); out: return error; out_status: return nfs_stat_to_errno(status); } static int <API key>(struct xdr_stream *xdr, struct nfs_pathconf *result) { __be32 *p; p = xdr_inline_decode(xdr, 4 * 6); if (unlikely(p == NULL)) goto out_overflow; result->max_link = be32_to_cpup(p++); result->max_namelen = be32_to_cpup(p); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_pathconf *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = <API key>(xdr, result); out: return error; out_status: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_writeres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; error = decode_wcc_data(xdr, result->fattr); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_status; error = decode_writeverf3(xdr, result->verf->verifier); out: return error; out_status: return nfs_stat_to_errno(status); } #ifdef CONFIG_NFS_V3_ACL static inline int decode_getacl3resok(struct xdr_stream *xdr, struct nfs3_getaclres *result) { struct posix_acl **acl; unsigned int *aclcnt; size_t hdrlen; int error; error = decode_post_op_attr(xdr, result->fattr); if (unlikely(error)) goto out; error = decode_uint32(xdr, &result->mask); if (unlikely(error)) goto out; error = -EINVAL; if (result->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT)) goto out; hdrlen = (u8 *)xdr->p - (u8 *)xdr->iov->iov_base; acl = NULL; if (result->mask & NFS_ACL) acl = &result->acl_access; aclcnt = NULL; if (result->mask & NFS_ACLCNT) aclcnt = &result->acl_access_count; error = nfsacl_decode(xdr->buf, hdrlen, aclcnt, acl); if (unlikely(error <= 0)) goto out; acl = NULL; if (result->mask & NFS_DFACL) acl = &result->acl_default; aclcnt = NULL; if (result->mask & NFS_DFACLCNT) aclcnt = &result->acl_default_count; error = nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl); if (unlikely(error <= 0)) return error; error = 0; out: return error; } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs3_getaclres *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_getacl3resok(xdr, result); out: return error; out_default: return nfs_stat_to_errno(status); } static int <API key>(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs_fattr *result) { enum nfs_stat status; int error; error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; if (status != NFS3_OK) goto out_default; error = decode_post_op_attr(xdr, result); out: return error; out_default: return nfs_stat_to_errno(status); } #endif #define PROC(proc, argtype, restype, timer) \ [NFS3PROC_##proc] = { \ .p_proc = NFS3PROC_##proc, \ .p_encode = (kxdreproc_t)nfs3_xdr_enc_##argtype##3args, \ .p_decode = (kxdrdproc_t)nfs3_xdr_dec_##restype##3res, \ .p_arglen = NFS3_##argtype##args_sz, \ .p_replen = NFS3_##restype##res_sz, \ .p_timer = timer, \ .p_statidx = NFS3PROC_##proc, \ .p_name = #proc, \ } struct rpc_procinfo nfs3_procedures[] = { PROC(GETATTR, getattr, getattr, 1), PROC(SETATTR, setattr, setattr, 0), PROC(LOOKUP, lookup, lookup, 2), PROC(ACCESS, access, access, 1), PROC(READLINK, readlink, readlink, 3), PROC(READ, read, read, 3), PROC(WRITE, write, write, 4), PROC(CREATE, create, create, 0), PROC(MKDIR, mkdir, create, 0), PROC(SYMLINK, symlink, create, 0), PROC(MKNOD, mknod, create, 0), PROC(REMOVE, remove, remove, 0), PROC(RMDIR, lookup, setattr, 0), PROC(RENAME, rename, rename, 0), PROC(LINK, link, link, 0), PROC(READDIR, readdir, readdir, 3), PROC(READDIRPLUS, readdirplus, readdir, 3), PROC(FSSTAT, getattr, fsstat, 0), PROC(FSINFO, getattr, fsinfo, 0), PROC(PATHCONF, getattr, pathconf, 0), PROC(COMMIT, commit, commit, 5), }; const struct rpc_version nfs_version3 = { .number = 3, .nrprocs = ARRAY_SIZE(nfs3_procedures), .procs = nfs3_procedures }; #ifdef CONFIG_NFS_V3_ACL static struct rpc_procinfo nfs3_acl_procedures[] = { [ACLPROC3_GETACL] = { .p_proc = ACLPROC3_GETACL, .p_encode = (kxdreproc_t)<API key>, .p_decode = (kxdrdproc_t)<API key>, .p_arglen = ACL3_getaclargs_sz, .p_replen = ACL3_getaclres_sz, .p_timer = 1, .p_name = "GETACL", }, [ACLPROC3_SETACL] = { .p_proc = ACLPROC3_SETACL, .p_encode = (kxdreproc_t)<API key>, .p_decode = (kxdrdproc_t)<API key>, .p_arglen = ACL3_setaclargs_sz, .p_replen = ACL3_setaclres_sz, .p_timer = 0, .p_name = "SETACL", }, }; const struct rpc_version nfsacl_version3 = { .number = 3, .nrprocs = sizeof(nfs3_acl_procedures)/ sizeof(nfs3_acl_procedures[0]), .procs = nfs3_acl_procedures, }; #endif
using System; using Server; using Server.Items; namespace Server.Items { public class BloodOathScroll : SpellScroll { [Constructable] public BloodOathScroll() : this( 1 ) { } [Constructable] public BloodOathScroll( int amount ) : base( 101, 0x2261, amount ) { } public BloodOathScroll( Serial serial ) : base( serial ) { } public override void Serialize( GenericWriter writer ) { base.Serialize( writer ); writer.Write( (int) 0 ); // version } public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); } } }
<!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>FormattingTuple xref</title> <link type="text/css" rel="stylesheet" href="../../../stylesheet.css" /> </head> <body> <div id="overview"><a href="../../../../apidocs/org/slf4j/helpers/FormattingTuple.html">View Javadoc</a></div><pre> <a class="jxr_linenumber" name="25" href="#25">25</a> <strong class="jxr_keyword">package</strong> org.slf4j.helpers; <a class="jxr_linenumber" name="26" href="#26">26</a> <a class="jxr_linenumber" name="27" href="#27">27</a> <em class="jxr_javadoccomment">/**</em> <a class="jxr_linenumber" name="28" href="#28">28</a> <em class="jxr_javadoccomment"> * Holds the results of formatting done by {@link MessageFormatter}.</em> <a class="jxr_linenumber" name="29" href="#29">29</a> <em class="jxr_javadoccomment"> * </em> <a class="jxr_linenumber" name="30" href="#30">30</a> <em class="jxr_javadoccomment"> * @author Joern Huxhorn</em> <a class="jxr_linenumber" name="31" href="#31">31</a> <em class="jxr_javadoccomment"> */</em> <a class="jxr_linenumber" name="32" href="#32">32</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../org/slf4j/helpers/FormattingTuple.html">FormattingTuple</a> { <a class="jxr_linenumber" name="33" href="#33">33</a> <a class="jxr_linenumber" name="34" href="#34">34</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">public</strong> <a href="../../../org/slf4j/helpers/FormattingTuple.html">FormattingTuple</a> NULL = <strong class="jxr_keyword">new</strong> <a href="../../../org/slf4j/helpers/FormattingTuple.html">FormattingTuple</a>(<strong class="jxr_keyword">null</strong>); <a class="jxr_linenumber" name="35" href="#35">35</a> <a class="jxr_linenumber" name="36" href="#36">36</a> <strong class="jxr_keyword">private</strong> String message; <a class="jxr_linenumber" name="37" href="#37">37</a> <strong class="jxr_keyword">private</strong> Throwable throwable; <a class="jxr_linenumber" name="38" href="#38">38</a> <strong class="jxr_keyword">private</strong> Object[] argArray; <a class="jxr_linenumber" name="39" href="#39">39</a> <a class="jxr_linenumber" name="40" href="#40">40</a> <strong class="jxr_keyword">public</strong> <a href="../../../org/slf4j/helpers/FormattingTuple.html">FormattingTuple</a>(String message) { <a class="jxr_linenumber" name="41" href="#41">41</a> <strong class="jxr_keyword">this</strong>(message, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>); <a class="jxr_linenumber" name="42" href="#42">42</a> } <a class="jxr_linenumber" name="43" href="#43">43</a> <a class="jxr_linenumber" name="44" href="#44">44</a> <strong class="jxr_keyword">public</strong> <a href="../../../org/slf4j/helpers/FormattingTuple.html">FormattingTuple</a>(String message, Object[] argArray, Throwable throwable) { <a class="jxr_linenumber" name="45" href="#45">45</a> <strong class="jxr_keyword">this</strong>.message = message; <a class="jxr_linenumber" name="46" href="#46">46</a> <strong class="jxr_keyword">this</strong>.throwable = throwable; <a class="jxr_linenumber" name="47" href="#47">47</a> <strong class="jxr_keyword">this</strong>.argArray = argArray; <a class="jxr_linenumber" name="48" href="#48">48</a> } <a class="jxr_linenumber" name="49" href="#49">49</a> <a class="jxr_linenumber" name="50" href="#50">50</a> <strong class="jxr_keyword">public</strong> String getMessage() { <a class="jxr_linenumber" name="51" href="#51">51</a> <strong class="jxr_keyword">return</strong> message; <a class="jxr_linenumber" name="52" href="#52">52</a> } <a class="jxr_linenumber" name="53" href="#53">53</a> <a class="jxr_linenumber" name="54" href="#54">54</a> <strong class="jxr_keyword">public</strong> Object[] getArgArray() { <a class="jxr_linenumber" name="55" href="#55">55</a> <strong class="jxr_keyword">return</strong> argArray; <a class="jxr_linenumber" name="56" href="#56">56</a> } <a class="jxr_linenumber" name="57" href="#57">57</a> <a class="jxr_linenumber" name="58" href="#58">58</a> <strong class="jxr_keyword">public</strong> Throwable getThrowable() { <a class="jxr_linenumber" name="59" href="#59">59</a> <strong class="jxr_keyword">return</strong> throwable; <a class="jxr_linenumber" name="60" href="#60">60</a> } <a class="jxr_linenumber" name="61" href="#61">61</a> <a class="jxr_linenumber" name="62" href="#62">62</a> } </pre> <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body> </html>
//var waitImg1 = 'busy/<API key>.gif'; //var waitImg2 = 'busy/busy-phplist_black.gif'; //var waitImg3 = 'busy/busy-phplist_mix.gif'; $(document).ready(function() { var waitimg = new Image(); waitimg.src = waitImage; $("#<API key>").submit(function() { var emailaddress = $("#emailaddress").val(); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var subscribeaddress = this.action; var ajaxaddress = subscribeaddress.replace(/subscribe/,'asubscribe'); $(' if(emailReg.test(emailaddress)) { var jqxhr = $.ajax({ type: 'POST', url: ajaxaddress, crossDomain: true, data: "email="+emailaddress, success: function(data, textStatus, jqXHR ) { if (data.search(/FAIL/) >= 0) { document.location = subscribeaddress+"&email="+emailaddress; } else { $('#<API key>').html("<div id='subscribemessage'></div>"); $('#subscribemessage').html(data) .hide() .fadeIn(1500); $("#<API key>").hide(); document.cookie = "phplistsubscribed=yes"; } }, error: function(jqXHR, textStatus, errorThrown) { document.location = subscribeaddress+"&email="+emailaddress; } }); } else { document.location = subscribeaddress+"&email="+emailaddress; } return false; }); $("#emailaddress").val(pleaseEnter); $("#emailaddress").focus(function() { var v = $("#emailaddress").val(); if (v == pleaseEnter) { $("#emailaddress").val("") } }); $("#emailaddress").blur(function() { var v = $("#emailaddress").val(); if (v == "") { $("#emailaddress").val(pleaseEnter) } }); var cookie = document.cookie; if (cookie.indexOf('phplistsubscribed=yes')>=0) { $("#<API key>").html(<API key>); } }); // cross domain fix for IE $.ajaxTransport("+*", function( options, originalOptions, jqXHR ) { if(jQuery.browser.msie && window.XDomainRequest) { var xdr; return { send: function( headers, completeCallback ) { // Use Microsoft XDR xdr = new XDomainRequest(); // would be nicer to keep it post xdr.open("get", options.url+"&"+options.data); xdr.onload = function() { if(this.contentType.match(/\/xml/)){ var dom = new ActiveXObject("Microsoft.XMLDOM"); dom.async = false; dom.loadXML(this.responseText); completeCallback(200, "success", [dom]); } else { completeCallback(200, "success", [this.responseText]); } }; xdr.ontimeout = function(){ completeCallback(408, "error", ["The request timed out."]); }; xdr.onerror = function(){ completeCallback(404, "error", ["The requested resource could not be found."]); }; xdr.send(); }, abort: function() { if(xdr)xdr.abort(); } }; } }); if (pleaseEnter == undefined) { var pleaseEnter = "Please enter your email"; } if (<API key> == undefined) { var <API key> = '<div class="subscribed">Thanks for subscribing. Please click the link in the confirmation email you will receive.</div>'; } if (waitImage == undefined) { var waitImage = 'https://s3.amazonaws.com/phplist/img/busy.gif'; }
/* * NOTE: * Because of various external restrictions (i.e. US export * regulations, etc.), the actual source code can not be provided * at this time. This file represents the skeleton of the source * file, so that javadocs of the API can be created. */ package javax.crypto; import java.security.*; /** * This exception is thrown when a particular padding mechanism is * requested but is not available in the environment. * */ public class <API key> extends <API key> { /** * Constructs a <API key> with no detail * message. A detail message is a String that describes this * particular exception. */ public <API key>() { super(); } /** * Constructs a <API key> with the specified * detail message. A detail message is a String that describes * this particular exception, which may, for example, specify which * algorithm is not available. * * @param msg the detail message. */ public <API key>(String msg) { super(msg); } }
#include <config.h> #include "ColorSet.h" #include "InsetMathColor.h" #include "LaTeXFeatures.h" #include "MathData.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" #include <ostream> namespace lyx { InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color) : InsetMathNest(buf, 1), oldstyle_(oldstyle), color_(from_utf8(lcolor.getLaTeXName(color))) {} InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle, docstring const & color) : InsetMathNest(buf, 1), oldstyle_(oldstyle), color_(color) {} Inset * InsetMathColor::clone() const { return new InsetMathColor(*this); } void InsetMathColor::metrics(MetricsInfo & mi, Dimension & dim) const { cell(0).metrics(mi, dim); metricsMarkers(dim); } void InsetMathColor::draw(PainterInfo & pi, int x, int y) const { ColorCode origcol = pi.base.font.color(); pi.base.font.setColor(lcolor.getFromLaTeXName(to_utf8(color_))); cell(0).draw(pi, x + 1, y); pi.base.font.setColor(origcol); drawMarkers(pi, x, y); setPosCache(pi, x, y); } color "none" (reset to default) needs special treatment static bool normalcolor(docstring const & color) { return color == "none"; } void InsetMathColor::validate(LaTeXFeatures & features) const { InsetMathNest::validate(features); if (!normalcolor(color_)) features.require("color"); } void InsetMathColor::write(WriteStream & os) const { if (normalcolor(color_)) // reset to default color inside another color inset os << "{\\normalcolor " << cell(0) << '}'; else if (oldstyle_) os << "{\\color{" << color_ << '}' << cell(0) << '}'; else os << "\\textcolor{" << color_ << "}{" << cell(0) << '}'; } void InsetMathColor::normalize(NormalStream & os) const { os << "[color " << color_ << ' ' << cell(0) << ']'; } void InsetMathColor::infoize(odocstream & os) const { os << "Color: " << color_; } } // namespace lyx
#ifndef __XFS_VFS_H__ #define __XFS_VFS_H__ #include <linux/vfs.h> #include "xfs_fs.h" struct fid; struct vfs; struct cred; struct vnode; struct statfs; struct seq_file; struct super_block; struct xfs_mount_args; typedef struct statfs xfs_statfs_t; typedef struct vfs_sync_work { struct list_head w_list; struct vfs *w_vfs; void *w_data; /* syncer routine argument */ void (*w_syncer)(struct vfs *, void *); } vfs_sync_work_t; typedef struct vfs { u_int vfs_flag; /* flags */ xfs_fsid_t vfs_fsid; /* file system ID */ xfs_fsid_t *vfs_altfsid; /* An ID fixed for life of FS */ bhv_head_t vfs_bh; /* head of vfs behavior chain */ struct super_block *vfs_super; /* generic superblock pointer */ struct task_struct *vfs_sync_task; /* generalised sync thread */ vfs_sync_work_t vfs_sync_work; /* work item for VFS_SYNC */ struct list_head vfs_sync_list; /* sync thread work item list */ spinlock_t vfs_sync_lock; /* work item list lock */ wait_queue_head_t vfs_wait_sync_task; int vfs_frozen; wait_queue_head_t vfs_wait_unfrozen; } vfs_t; #define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */ #define bhvtovfs(bdp) ( (struct vfs *)BHV_VOBJ(bdp) ) #define bhvtovfsops(bdp) ( (struct vfsops *)BHV_OPS(bdp) ) #define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh ) #define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) ) #define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */ #define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */ #define <API key> <API key> /* invalid pos. num */ typedef enum { VFS_BHV_UNKNOWN, /* not specified */ VFS_BHV_XFS, /* xfs */ VFS_BHV_DM, /* data migration */ VFS_BHV_QM, /* quota manager */ VFS_BHV_IO, /* IO path */ VFS_BHV_END /* housekeeping end-of-range */ } vfs_bhv_t; #define VFS_POSITION_XFS (BHV_POSITION_BASE) #define VFS_POSITION_DM (VFS_POSITION_BASE+10) #define VFS_POSITION_QM (VFS_POSITION_BASE+20) #define VFS_POSITION_IO (VFS_POSITION_BASE+30) #define VFS_RDONLY 0x0001 /* read-only vfs */ #define VFS_GRPID 0x0002 /* group-ID assigned from directory */ #define VFS_DMI 0x0004 /* filesystem has the DMI enabled */ #define VFS_UMOUNT 0x0008 /* unmount in progress */ #define VFS_END 0x0008 /* max flag */ #define SYNC_ATTR 0x0001 /* sync attributes */ #define SYNC_CLOSE 0x0002 /* close file system down */ #define SYNC_DELWRI 0x0004 /* look at delayed writes */ #define SYNC_WAIT 0x0008 /* wait for i/o to complete */ #define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */ #define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */ #define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ #define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ #define IGET_NOALLOC 0x0001 /* vfs_get_inode may return NULL */ typedef int (*vfs_mount_t)(bhv_desc_t *, struct xfs_mount_args *, struct cred *); typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *, struct xfs_mount_args *, int); typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *); typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *); typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *, struct xfs_mount_args *); typedef int (*vfs_root_t)(bhv_desc_t *, struct vnode **); typedef int (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *); typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *); typedef int (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *); typedef int (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t); typedef int (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t); typedef void (*vfs_init_vnode_t)(bhv_desc_t *, struct vnode *, bhv_desc_t *, int); typedef void (*<API key>)(bhv_desc_t *, int, char *, int); typedef void (*vfs_freeze_t)(bhv_desc_t *); typedef struct inode * (*vfs_get_inode_t)(bhv_desc_t *, xfs_ino_t, int); typedef struct vfsops { bhv_position_t vf_position; /* behavior chain position */ vfs_mount_t vfs_mount; /* mount file system */ vfs_parseargs_t vfs_parseargs; /* parse mount options */ vfs_showargs_t vfs_showargs; /* unparse mount options */ vfs_unmount_t vfs_unmount; /* unmount file system */ vfs_mntupdate_t vfs_mntupdate; /* update file system options */ vfs_root_t vfs_root; /* get root vnode */ vfs_statvfs_t vfs_statvfs; /* file system statistics */ vfs_sync_t vfs_sync; /* flush files */ vfs_vget_t vfs_vget; /* get vnode from fid */ vfs_dmapiops_t vfs_dmapiops; /* data migration */ vfs_quotactl_t vfs_quotactl; /* disk quota */ vfs_get_inode_t vfs_get_inode; /* bhv specific iget */ vfs_init_vnode_t vfs_init_vnode; /* initialize a new vnode */ <API key> vfs_force_shutdown; /* crash and burn */ vfs_freeze_t vfs_freeze; /* freeze fs for snapshot */ } vfsops_t; /* * VFS's. Operates on vfs structure pointers (starts at bhv head). */ #define VHEAD(v) ((v)->vfs_fbhv) #define VFS_MOUNT(v, ma,cr, rv) ((rv) = vfs_mount(VHEAD(v), ma,cr)) #define VFS_PARSEARGS(v, o,ma,f, rv) ((rv) = vfs_parseargs(VHEAD(v), o,ma,f)) #define VFS_SHOWARGS(v, m, rv) ((rv) = vfs_showargs(VHEAD(v), m)) #define VFS_UNMOUNT(v, f, cr, rv) ((rv) = vfs_unmount(VHEAD(v), f,cr)) #define VFS_MNTUPDATE(v, fl, args, rv) ((rv) = vfs_mntupdate(VHEAD(v), fl, args)) #define VFS_ROOT(v, vpp, rv) ((rv) = vfs_root(VHEAD(v), vpp)) #define VFS_STATVFS(v, sp,vp, rv) ((rv) = vfs_statvfs(VHEAD(v), sp,vp)) #define VFS_SYNC(v, flag,cr, rv) ((rv) = vfs_sync(VHEAD(v), flag,cr)) #define VFS_VGET(v, vpp,fidp, rv) ((rv) = vfs_vget(VHEAD(v), vpp,fidp)) #define VFS_DMAPIOPS(v, p, rv) ((rv) = vfs_dmapiops(VHEAD(v), p)) #define VFS_QUOTACTL(v, c,id,p, rv) ((rv) = vfs_quotactl(VHEAD(v), c,id,p)) #define VFS_GET_INODE(v, ino, fl) ( vfs_get_inode(VHEAD(v), ino,fl) ) #define VFS_INIT_VNODE(v, vp,b,ul) ( vfs_init_vnode(VHEAD(v), vp,b,ul) ) #define VFS_FORCE_SHUTDOWN(v, fl,f,l) ( vfs_force_shutdown(VHEAD(v), fl,f,l) ) #define VFS_FREEZE(v) ( vfs_freeze(VHEAD(v)) ) /* * PVFS's. Operates on behavior descriptor pointers. */ #define PVFS_MOUNT(b, ma,cr, rv) ((rv) = vfs_mount(b, ma,cr)) #define PVFS_PARSEARGS(b, o,ma,f, rv) ((rv) = vfs_parseargs(b, o,ma,f)) #define PVFS_SHOWARGS(b, m, rv) ((rv) = vfs_showargs(b, m)) #define PVFS_UNMOUNT(b, f,cr, rv) ((rv) = vfs_unmount(b, f,cr)) #define PVFS_MNTUPDATE(b, fl, args, rv) ((rv) = vfs_mntupdate(b, fl, args)) #define PVFS_ROOT(b, vpp, rv) ((rv) = vfs_root(b, vpp)) #define PVFS_STATVFS(b, sp,vp, rv) ((rv) = vfs_statvfs(b, sp,vp)) #define PVFS_SYNC(b, flag,cr, rv) ((rv) = vfs_sync(b, flag,cr)) #define PVFS_VGET(b, vpp,fidp, rv) ((rv) = vfs_vget(b, vpp,fidp)) #define PVFS_DMAPIOPS(b, p, rv) ((rv) = vfs_dmapiops(b, p)) #define PVFS_QUOTACTL(b, c,id,p, rv) ((rv) = vfs_quotactl(b, c,id,p)) #define PVFS_GET_INODE(b, ino,fl) ( vfs_get_inode(b, ino,fl) ) #define PVFS_INIT_VNODE(b, vp,b2,ul) ( vfs_init_vnode(b, vp,b2,ul) ) #define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) ) #define PVFS_FREEZE(b) ( vfs_freeze(b) ) extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *); extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int); extern int vfs_showargs(bhv_desc_t *, struct seq_file *); extern int vfs_unmount(bhv_desc_t *, int, struct cred *); extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *); extern int vfs_root(bhv_desc_t *, struct vnode **); extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *); extern int vfs_sync(bhv_desc_t *, int, struct cred *); extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *); extern int vfs_dmapiops(bhv_desc_t *, caddr_t); extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t); extern struct inode *vfs_get_inode(bhv_desc_t *, xfs_ino_t, int); extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int); extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int); extern void vfs_freeze(bhv_desc_t *); typedef struct bhv_vfsops { struct vfsops bhv_common; void * bhv_custom; } bhv_vfsops_t; #define vfs_bhv_lookup(v, id) ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) ) #define vfs_bhv_custom(b) ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom ) #define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o)) #define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL ) extern vfs_t *vfs_allocate(void); extern void vfs_deallocate(vfs_t *); extern void vfs_insertops(vfs_t *, bhv_vfsops_t *); extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *); extern void <API key>(struct vfs *); extern void <API key>(struct vfs *, int); extern void bhv_remove_vfsops(struct vfs *, int); enum { SB_UNFROZEN = 0, SB_FREEZE_WRITE = 1, SB_FREEZE_TRANS = 2, }; #define fs_frozen(vfsp) ((vfsp)->vfs_frozen) #define fs_check_frozen(vfsp, level) \ wait_event((vfsp)->vfs_wait_unfrozen, ((vfsp)->vfs_frozen < (level))) #endif /* __XFS_VFS_H__ */
#ifndef POWERPC_85XX_SMP_H_ #define POWERPC_85XX_SMP_H_ 1 #include <linux/init.h> #ifdef CONFIG_SMP void __init mpc85xx_smp_init(void); #else static inline void mpc85xx_smp_init(void) { } #endif #endif
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http: <head> <title>Qt 4.4: List of All Members for Q3ServerSocket</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http: <td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="namespaces.html"><font color="#004faf">All&nbsp;Namespaces</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"></td></tr></table><h1 class="title">List of All Members for Q3ServerSocket</h1> <p>This is the complete list of members for <a href="q3serversocket.html" class="compat">Q3ServerSocket</a>, including inherited members.</p> <p><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td width="45%" valign="top"><ul> <li><div class="fn"/><a href="q3serversocket.html#Q3ServerSocket">Q3ServerSocket</a> ( Q_UINT16, int, QObject *, const char * )</li> <li><div class="fn"/><a href="q3serversocket.html#Q3ServerSocket-2">Q3ServerSocket</a> ( const QHostAddress &amp;, Q_UINT16, int, QObject *, const char * )</li> <li><div class="fn"/><a href="q3serversocket.html#Q3ServerSocket-3">Q3ServerSocket</a> ( QObject *, const char * )</li> <li><div class="fn"/><a href="q3serversocket.html#dtor.Q3ServerSocket">~Q3ServerSocket</a> ()</li> <li><div class="fn"/><a href="q3serversocket.html#address">address</a> () const : QHostAddress</li> <li><div class="fn"/><a href="qobject.html#blockSignals">blockSignals</a> ( bool ) : bool</li> <li><div class="fn"/><a href="qobject.html#childEvent">childEvent</a> ( QChildEvent * )</li> <li><div class="fn"/><a href="qobject.html#children">children</a> () const : const QObjectList &amp;</li> <li><div class="fn"/><a href="qobject.html#connect">connect</a> ( const QObject *, const char *, const QObject *, const char *, Qt::ConnectionType ) : bool</li> <li><div class="fn"/><a href="qobject.html#connect-2">connect</a> ( const QObject *, const char *, const char *, Qt::ConnectionType ) const : bool</li> <li><div class="fn"/><a href="qobject.html#connectNotify">connectNotify</a> ( const char * )</li> <li><div class="fn"/><a href="qobject.html#customEvent">customEvent</a> ( QEvent * )</li> <li><div class="fn"/><a href="qobject.html#d_ptr-var">d_ptr</a> : QObjectData *</li> <li><div class="fn"/><a href="qobject.html#deleteLater">deleteLater</a> ()</li> <li><div class="fn"/><a href="qobject.html#destroyed">destroyed</a> ( QObject * )</li> <li><div class="fn"/><a href="qobject.html#disconnect">disconnect</a> ( const QObject *, const char *, const QObject *, const char * ) : bool</li> <li><div class="fn"/><a href="qobject.html#disconnect-2">disconnect</a> ( const char *, const QObject *, const char * ) : bool</li> <li><div class="fn"/><a href="qobject.html#disconnect-3">disconnect</a> ( const QObject *, const char * ) : bool</li> <li><div class="fn"/><a href="qobject.html#disconnectNotify">disconnectNotify</a> ( const char * )</li> <li><div class="fn"/><a href="qobject.html#dumpObjectInfo">dumpObjectInfo</a> ()</li> <li><div class="fn"/><a href="qobject.html#dumpObjectTree">dumpObjectTree</a> ()</li> <li><div class="fn"/><a href="qobject.html#<API key>"><API key></a> () const : QList&lt;QByteArray&gt;</li> <li><div class="fn"/><a href="qobject.html#event">event</a> ( QEvent * ) : bool</li> <li><div class="fn"/><a href="qobject.html#eventFilter">eventFilter</a> ( QObject *, QEvent * ) : bool</li> <li><div class="fn"/><a href="qobject.html#findChild">findChild</a> ( const QString &amp; ) const : T</li> <li><div class="fn"/><a href="qobject.html#findChildren">findChildren</a> ( const QString &amp; ) const : QList&lt;T&gt;</li> <li><div class="fn"/><a href="qobject.html#findChildren-2">findChildren</a> ( const QRegExp &amp; ) const : QList&lt;T&gt;</li> <li><div class="fn"/><a href="qobject.html#inherits">inherits</a> ( const char * ) const : bool</li> </ul></td><td valign="top"><ul> <li><div class="fn"/><a href="qobject.html#installEventFilter">installEventFilter</a> ( QObject * )</li> <li><div class="fn"/><a href="qobject.html#isWidgetType">isWidgetType</a> () const : bool</li> <li><div class="fn"/><a href="qobject.html#killTimer">killTimer</a> ( int )</li> <li><div class="fn"/><a href="qobject.html#metaObject">metaObject</a> () const : const QMetaObject *</li> <li><div class="fn"/><a href="qobject.html#moveToThread">moveToThread</a> ( QThread * )</li> <li><div class="fn"/><a href="q3serversocket.html#newConnection">newConnection</a> ( int )</li> <li><div class="fn"/><a href="qobject.html#objectName-prop">objectName</a> () const : QString</li> <li><div class="fn"/><a href="q3serversocket.html#ok">ok</a> () const : bool</li> <li><div class="fn"/><a href="qobject.html#parent">parent</a> () const : QObject *</li> <li><div class="fn"/><a href="q3serversocket.html#port">port</a> () const : Q_UINT16</li> <li><div class="fn"/><a href="qobject.html#property">property</a> ( const char * ) const : QVariant</li> <li><div class="fn"/><a href="qobject.html#receivers">receivers</a> ( const char * ) const : int</li> <li><div class="fn"/><a href="qobject.html#removeEventFilter">removeEventFilter</a> ( QObject * )</li> <li><div class="fn"/><a href="qobject.html#sender">sender</a> () const : QObject *</li> <li><div class="fn"/><a href="qobject.html#objectName-prop">setObjectName</a> ( const QString &amp; )</li> <li><div class="fn"/><a href="qobject.html#setParent">setParent</a> ( QObject * )</li> <li><div class="fn"/><a href="qobject.html#setProperty">setProperty</a> ( const char *, const QVariant &amp; ) : bool</li> <li><div class="fn"/><a href="q3serversocket.html#setSocket">setSocket</a> ( int )</li> <li><div class="fn"/><a href="qobject.html#signalsBlocked">signalsBlocked</a> () const : bool</li> <li><div class="fn"/><a href="q3serversocket.html#socket">socket</a> () const : int</li> <li><div class="fn"/><a href="q3serversocket.html#socketDevice">socketDevice</a> () : Q3SocketDevice *</li> <li><div class="fn"/><a href="qobject.html#startTimer">startTimer</a> ( int ) : int</li> <li><div class="fn"/><a href="qobject.html#<API key>">staticMetaObject</a> : const QMetaObject</li> <li><div class="fn"/><a href="qobject.html#<API key>">staticQtMetaObject</a> : const QMetaObject</li> <li><div class="fn"/><a href="qobject.html#thread">thread</a> () const : QThread *</li> <li><div class="fn"/><a href="qobject.html#timerEvent">timerEvent</a> ( QTimerEvent * )</li> <li><div class="fn"/><a href="qobject.html#tr">tr</a> ( const char *, const char *, int ) : QString</li> <li><div class="fn"/><a href="qobject.html#trUtf8">trUtf8</a> ( const char *, const char *, int ) : QString</li> </ul> </td></tr> </table></p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%" align="left">Copyright &copy; 2008 Nokia</td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.4.3</div></td> </tr></table></div></address></body> </html>